#include "Memory2_lib.h"
#include <bits/stdc++.h>
using namespace std;
void Solve(int t, int n) {
vector<int> val(2*n, -1);
vector<vector<int>> st(n);
priority_queue<int> pq;
for (int i=0; i<2*n; i++) pq.emplace(i);
while (pq.size()) {
int x=pq.top();
pq.pop();
while (pq.size()) {
int y=pq.top();
pq.pop();
int r=Flip(x, y);
if (st[r].size()==2) {
val[x]=r;
pq.emplace(y);
for (auto &i:st[r]) pq.emplace(i);
for (int i=0; i<n; i++) {
if (i!=r) for (auto &j:st[i]) val[j]=i;
st[i].clear();
}
break;
}
st[r].emplace_back(y);
}
}
for (int i=0; i<2*n; i++) if (val[i]!=-1) st[val[i]].emplace_back(i);
int lx=n*(2*n-1);
for (auto &i:st) for (auto &j:i) lx-=j;
for (int i=0; i<n; i++) {
if (st[i].size()==1) st[i].emplace_back(lx);
Answer(st[i][0], st[i][1], i);
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
272 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Incorrect |
1 ms |
204 KB |
Wrong Answer[3] |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Runtime error |
1 ms |
292 KB |
Execution killed with signal 11 |
6 |
Halted |
0 ms |
0 KB |
- |