#include "Memory2_lib.h"
#include<bits/stdc++.h>
using namespace std;
void Solve(int T, int N){
vector<int> p(2*N,-1),cnt(N,0);
vector<vector<int>> res(2*N,vector<int>(2*N,-1));
auto query = [&](int i,int j){
if(res[i][j]!=-1) return res[i][j];
return res[i][j]=res[j][i]=Flip(i,j);
};
vector<int> cur={0,1};
auto change = [&](){
for(int x:cur){
for(int y:cur){
if(x==y) continue;
for(int z:cur){
if(z==x || z==y) continue;
int a=query(x,y),b=query(x,z),c=query(y,z);
if(a==b && a!=c) p[x]=a;
}
}
}
vector<int> nw;
for(int x:cur) if(p[x]==-1) nw.push_back(x);
cur=nw;
};
for(int i=2;i<2*N;i++) cur.push_back(i),change();
for(int i=0;i<2*N;i++) if(p[i]!=-1) cnt[p[i]]++;
for(int i=0;i<N;i++) if(cnt[p[i]]!=2) cur.push_back(i);
cnt.assign(N,0);change();
int num=0;
for(int i=0;i<2*N;i++) if(p[i]!=-1) cnt[p[i]]++;
while(cnt[num]==2) num++;
for(int i=0;i<2*N;i++) if(p[i]==-1) p[i]=num;
vector<vector<int>> ans(N);
for(int i=0;i<2*N;i++) ans[p[i]].push_back(i);
for(int i=0;i<N;i++) Answer(ans[i][0],ans[i][1],i);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
296 KB |
Output is correct |
5 |
Correct |
1 ms |
300 KB |
Output is correct |
6 |
Correct |
0 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
300 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
296 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
0 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
304 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
300 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |