#include<bits/stdc++.h>
#include "library.h"
#define all(vec) vec.begin(),vec.end()
using namespace std;
using ll=long long;
using P=pair<int,int>;
const ll MOD=1000000007LL;
const ll INF=(1<<30);
const ll LINF=(1LL<<60);
template<typename T> void chmax(T &a,T b){a=max(a,b);}
template<typename T> void chmin(T &a,T b){a=min(a,b);}
void Solve(int N){
if(N==1){
Answer(vector<int>(1,1));
return;
}
int pos;
vector<int> vis(N+10);
for(int i=1;i<=N;i++){
vector<int> v(N);
for(int j=1;j<=N;j++){
if(i==j)continue;
v[j-1]=1;
}
int q=Query(v);
if(q==1){
pos=i;
vis[pos]=1;
break;
}
}
vector<int> ans;
ans.push_back(pos);
for(int i=0;i<N-1;i++){
vector<int> v,vv(N);
for(int j=1;j<=N;j++){
if(vis[j])continue;
v.push_back(j);
}
sort(all(v));
int ng=0,ok=v.size();
while(ok-ng>1){
int mid=(ok+ng)/2;
for(int j=0;j<N;j++)vv[j]=0;
for(int j=0;j<mid;j++)vv[v[j]-1]=1;
int q1=Query(vv);
vv[pos-1]=1;
int q2=Query(vv);
if(q1==q2){
ok=mid;
}else{
ng=mid;
}
}
pos=v[ok-1];
vis[pos]=1;
ans.push_back(pos);
}
Answer(ans);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
41 ms |
384 KB |
# of queries: 2375 |
2 |
Correct |
60 ms |
408 KB |
# of queries: 2409 |
3 |
Correct |
44 ms |
384 KB |
# of queries: 2648 |
4 |
Correct |
48 ms |
256 KB |
# of queries: 2595 |
5 |
Correct |
50 ms |
256 KB |
# of queries: 2508 |
6 |
Correct |
75 ms |
412 KB |
# of queries: 2551 |
7 |
Correct |
46 ms |
256 KB |
# of queries: 2544 |
8 |
Correct |
53 ms |
408 KB |
# of queries: 2420 |
9 |
Correct |
28 ms |
428 KB |
# of queries: 2546 |
10 |
Correct |
16 ms |
324 KB |
# of queries: 1474 |
11 |
Correct |
2 ms |
256 KB |
# of queries: 0 |
12 |
Correct |
3 ms |
256 KB |
# of queries: 1 |
13 |
Correct |
2 ms |
300 KB |
# of queries: 4 |
14 |
Correct |
2 ms |
256 KB |
# of queries: 7 |
15 |
Correct |
3 ms |
256 KB |
# of queries: 77 |
16 |
Correct |
6 ms |
256 KB |
# of queries: 183 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
41 ms |
384 KB |
# of queries: 2375 |
2 |
Correct |
60 ms |
408 KB |
# of queries: 2409 |
3 |
Correct |
44 ms |
384 KB |
# of queries: 2648 |
4 |
Correct |
48 ms |
256 KB |
# of queries: 2595 |
5 |
Correct |
50 ms |
256 KB |
# of queries: 2508 |
6 |
Correct |
75 ms |
412 KB |
# of queries: 2551 |
7 |
Correct |
46 ms |
256 KB |
# of queries: 2544 |
8 |
Correct |
53 ms |
408 KB |
# of queries: 2420 |
9 |
Correct |
28 ms |
428 KB |
# of queries: 2546 |
10 |
Correct |
16 ms |
324 KB |
# of queries: 1474 |
11 |
Correct |
2 ms |
256 KB |
# of queries: 0 |
12 |
Correct |
3 ms |
256 KB |
# of queries: 1 |
13 |
Correct |
2 ms |
300 KB |
# of queries: 4 |
14 |
Correct |
2 ms |
256 KB |
# of queries: 7 |
15 |
Correct |
3 ms |
256 KB |
# of queries: 77 |
16 |
Correct |
6 ms |
256 KB |
# of queries: 183 |
17 |
Correct |
449 ms |
412 KB |
# of queries: 17982 |
18 |
Correct |
462 ms |
416 KB |
# of queries: 17293 |
19 |
Correct |
529 ms |
384 KB |
# of queries: 17467 |
20 |
Correct |
427 ms |
384 KB |
# of queries: 16325 |
21 |
Correct |
390 ms |
328 KB |
# of queries: 15324 |
22 |
Correct |
503 ms |
256 KB |
# of queries: 17669 |
23 |
Correct |
456 ms |
384 KB |
# of queries: 17224 |
24 |
Correct |
160 ms |
376 KB |
# of queries: 7915 |
25 |
Correct |
486 ms |
432 KB |
# of queries: 17136 |
26 |
Correct |
362 ms |
256 KB |
# of queries: 15963 |
27 |
Correct |
177 ms |
256 KB |
# of queries: 8040 |
28 |
Correct |
479 ms |
384 KB |
# of queries: 15957 |
29 |
Correct |
439 ms |
256 KB |
# of queries: 15939 |
30 |
Correct |
399 ms |
412 KB |
# of queries: 15957 |