QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#419917 | #403. Memory2 | zhoukangyang# | 100 ✓ | 1ms | 4076kb | C++14 | 2.1kb | 2024-05-24 12:41:38 | 2024-05-24 12:41:40 |
Judging History
answer
#include <bits/stdc++.h>
#include "Memory2_lib.h"
#define L(i, j, k) for(int i = (j); i <= (k); ++i)
#define R(i, j, k) for(int i = (j); i >= (k); --i)
#define ll long long
#define sz(a) ((int) (a).size())
#define vi vector < int >
#define me(a, x) memset(a, x, sizeof(a))
#define ull unsigned long long
#define ld __float128
#define pb emplace_back
using namespace std;
void Solve(int T, int N) {
vi cnt(N * 2 + 1);
vi val(N * 2 + 1);
vi S;
L(i, 0, N * 2 - 1) {
S.pb(i);
}
vi ns(N * 2);
while (sz(S)) {
// cout<<"SZ="<<sz(S)<<endl;
// for(auto&u : S) {
// cout << u << ' ';
// }
// cout << endl;
vi cur(N * 2 + 1);
vi nS;
int ans = -1, pos = -1;
L(i, 1, sz(S) - 1) {
// cout << "query " << S[0] << ' ' << S[i] << endl;
val[i] = Flip(S[0], S[i]);
++cur[val[i]];
if (cur[val[i]] + cnt[val[i]] == 3) {
ans = val[i], pos = i;
L(j, i + 1, sz(S) - 1) {
nS.pb(S[j]);
}
break;
}
}
// cout << cnt[0] << ' ' << cnt[1] << ' ' << cnt[2] << endl;
// cout<<"S="<<S[0]<<' '<<S[1]<<' '<<S[2]<<' '<<ans<<' '<<sz(S)<<endl;
if (ans != -1) {
ns[S[0]] = ans;
++cnt[ans];
L(j, 1, pos) {
if (val[j] != ans) {
ns[S[j]] = val[j];
++cnt[val[j]];
} else {
nS.pb(S[j]);
}
}
swap(S, nS);
continue;
}
L(j, 0, N - 1) {
if (cur[j] + cnt[j] == 1) {
ans = j;
}
}
L(j, 1, sz(S) - 1) {
ns[S[j]] = val[j];
}
ns[S[0]] = ans;
break;
}
vector < vi > pt(N, vi(0));
// L(i, 0, N * 2 - 1) cout << ns[i] << ' ';
// cout << endl;
L(i, 0, N * 2 - 1) pt[ns[i]].pb(i);
L(i, 0, N - 1) Answer(pt[i][0], pt[i][1], i);
return;
}
详细
Subtask #1:
score: 10
Accepted
Test #1:
score: 10
Accepted
time: 0ms
memory: 3760kb
Test #2:
score: 10
Accepted
time: 0ms
memory: 3856kb
Test #3:
score: 10
Accepted
time: 0ms
memory: 3772kb
Test #4:
score: 10
Accepted
time: 0ms
memory: 4048kb
Test #5:
score: 10
Accepted
time: 0ms
memory: 3792kb
Test #6:
score: 10
Accepted
time: 0ms
memory: 3760kb
Test #7:
score: 10
Accepted
time: 0ms
memory: 3820kb
Test #8:
score: 10
Accepted
time: 0ms
memory: 3764kb
Subtask #2:
score: 50
Accepted
Test #9:
score: 50
Accepted
time: 1ms
memory: 4056kb
Test #10:
score: 50
Accepted
time: 1ms
memory: 3840kb
Test #11:
score: 50
Accepted
time: 1ms
memory: 3836kb
Test #12:
score: 50
Accepted
time: 0ms
memory: 4052kb
Test #13:
score: 50
Accepted
time: 0ms
memory: 4060kb
Test #14:
score: 50
Accepted
time: 0ms
memory: 4048kb
Test #15:
score: 50
Accepted
time: 1ms
memory: 4052kb
Test #16:
score: 50
Accepted
time: 0ms
memory: 3860kb
Test #17:
score: 50
Accepted
time: 1ms
memory: 3860kb
Test #18:
score: 50
Accepted
time: 1ms
memory: 4024kb
Subtask #3:
score: 40
Accepted
Test #19:
score: 40
Accepted
time: 1ms
memory: 3764kb
Test #20:
score: 40
Accepted
time: 1ms
memory: 4056kb
Test #21:
score: 40
Accepted
time: 0ms
memory: 3768kb
Test #22:
score: 40
Accepted
time: 0ms
memory: 3760kb
Test #23:
score: 40
Accepted
time: 0ms
memory: 4076kb
Test #24:
score: 40
Accepted
time: 1ms
memory: 3796kb
Test #25:
score: 40
Accepted
time: 0ms
memory: 4060kb
Test #26:
score: 40
Accepted
time: 0ms
memory: 4052kb
Test #27:
score: 40
Accepted
time: 0ms
memory: 4024kb
Test #28:
score: 40
Accepted
time: 0ms
memory: 3776kb
Extra Test:
score: 0
Extra Test Passed