#include "dango3.h"
#include <bits/stdc++.h>
using namespace std;
int n,m;
int Query2(vector<int> v){
vector<int> u;
vector<bool> have(n*m+1);
for(int x:v) have[x]=1;
for(int i=1; i<=n*m; i++){
if(!have[i]) u.push_back(i);
}
return m-Query(u);
}
void Solve(int N, int M) {
n=N, m=M;
vector<vector<int>> dango(M);
for(int i=1; i<=N*M; i++){
auto check=[&](int k)->bool{
dango[k-1].push_back(i);
int r=Query2(dango[k-1]);
dango[k-1].pop_back();
return r==2;
};
int j=0;
for(int k=31-__builtin_clz(M); k>=0; k--){
if(j+(1<<k)<M && check(j+(1<<k))) j+=(1<<k);
}
dango[j].push_back(i);
}
for(int i=0; i<M; i++) Answer(dango[i]);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
0 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 |
0 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
30 ms |
372 KB |
Output is correct |
2 |
Correct |
31 ms |
368 KB |
Output is correct |
3 |
Correct |
28 ms |
360 KB |
Output is correct |
4 |
Correct |
31 ms |
368 KB |
Output is correct |
5 |
Correct |
31 ms |
372 KB |
Output is correct |
6 |
Correct |
33 ms |
368 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1051 ms |
456 KB |
Output is correct |
2 |
Correct |
1048 ms |
576 KB |
Output is correct |
3 |
Correct |
997 ms |
484 KB |
Output is correct |
4 |
Correct |
1004 ms |
596 KB |
Output is correct |
5 |
Correct |
1014 ms |
592 KB |
Output is correct |
6 |
Correct |
944 ms |
468 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3940 ms |
704 KB |
Output is correct |
2 |
Correct |
4132 ms |
592 KB |
Output is correct |
3 |
Correct |
4177 ms |
644 KB |
Output is correct |
4 |
Correct |
3989 ms |
736 KB |
Output is correct |
5 |
Correct |
4059 ms |
532 KB |
Output is correct |
6 |
Correct |
3955 ms |
712 KB |
Output is correct |