#include "library.h"
#include <bits/stdc++.h>
#define f first
#define s second
#define vec vector
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pw(x) (1LL<<(x))
#define sz(x) (int)(x).size()
#define m_p make_pair
#define fast_prep ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef long double ld;
template<class T> bool umin(T &a,const T &b){return (a>b?a=b,1:0);}
template<class T> bool umax(T &a,const T &b){return (a<b?a=b,1:0);}
void Solve(int n){
if(n==1){
Answer({1});
return;
}
vec<int> ans;
for(int i=0;i<n;i++){
vec<int> h(n,1);
h[i]=0;
if(Query(h)==1)
ans.pb(i);
}
int last=ans.back();
ans.pop_back();
for(int i=1;i<n-1;i++){
vec<int> here;
vec<int>u(n);
for(auto &j : ans)
u[j]=1;
for(int j=0;j<n;j++){
if(!u[j])
here.pb(j);
}
while(sz(here)!=1){
vec<int> lft,rgt;
vec<int> ask(n,0);
for(int j=0;j<sz(here)/2;j++) ask[here[j]]=1,lft.pb(here[j]);
for(int j=sz(lft);j<sz(here);j++) rgt.pb(here[j]);
int fi=Query(ask);
ask[ans.back()]=1;
int si=Query(ask);
if(fi==si) here=lft;
else here=rgt;
}
ans.pb(here[0]);
}
ans.pb(last);
for(auto &z : ans) ++z;
// for(auto &z : ans)
// cout<<z<<' ';
// cout<<endl;
Answer(ans);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
35 ms |
208 KB |
# of queries: 2550 |
2 |
Correct |
39 ms |
208 KB |
# of queries: 2531 |
3 |
Correct |
37 ms |
208 KB |
# of queries: 2706 |
4 |
Correct |
45 ms |
208 KB |
# of queries: 2704 |
5 |
Correct |
37 ms |
208 KB |
# of queries: 2702 |
6 |
Correct |
46 ms |
208 KB |
# of queries: 2698 |
7 |
Correct |
40 ms |
208 KB |
# of queries: 2682 |
8 |
Correct |
46 ms |
208 KB |
# of queries: 2585 |
9 |
Correct |
36 ms |
208 KB |
# of queries: 2693 |
10 |
Correct |
22 ms |
208 KB |
# of queries: 1569 |
11 |
Correct |
0 ms |
208 KB |
# of queries: 0 |
12 |
Correct |
0 ms |
208 KB |
# of queries: 2 |
13 |
Correct |
1 ms |
288 KB |
# of queries: 5 |
14 |
Correct |
1 ms |
208 KB |
# of queries: 10 |
15 |
Correct |
1 ms |
208 KB |
# of queries: 91 |
16 |
Correct |
3 ms |
208 KB |
# of queries: 201 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
35 ms |
208 KB |
# of queries: 2550 |
2 |
Correct |
39 ms |
208 KB |
# of queries: 2531 |
3 |
Correct |
37 ms |
208 KB |
# of queries: 2706 |
4 |
Correct |
45 ms |
208 KB |
# of queries: 2704 |
5 |
Correct |
37 ms |
208 KB |
# of queries: 2702 |
6 |
Correct |
46 ms |
208 KB |
# of queries: 2698 |
7 |
Correct |
40 ms |
208 KB |
# of queries: 2682 |
8 |
Correct |
46 ms |
208 KB |
# of queries: 2585 |
9 |
Correct |
36 ms |
208 KB |
# of queries: 2693 |
10 |
Correct |
22 ms |
208 KB |
# of queries: 1569 |
11 |
Correct |
0 ms |
208 KB |
# of queries: 0 |
12 |
Correct |
0 ms |
208 KB |
# of queries: 2 |
13 |
Correct |
1 ms |
288 KB |
# of queries: 5 |
14 |
Correct |
1 ms |
208 KB |
# of queries: 10 |
15 |
Correct |
1 ms |
208 KB |
# of queries: 91 |
16 |
Correct |
3 ms |
208 KB |
# of queries: 201 |
17 |
Correct |
408 ms |
280 KB |
# of queries: 18122 |
18 |
Correct |
415 ms |
296 KB |
# of queries: 17975 |
19 |
Correct |
415 ms |
328 KB |
# of queries: 18162 |
20 |
Correct |
388 ms |
296 KB |
# of queries: 16966 |
21 |
Correct |
310 ms |
292 KB |
# of queries: 15915 |
22 |
Correct |
373 ms |
296 KB |
# of queries: 18190 |
23 |
Correct |
410 ms |
300 KB |
# of queries: 18143 |
24 |
Correct |
121 ms |
312 KB |
# of queries: 8359 |
25 |
Correct |
356 ms |
304 KB |
# of queries: 17739 |
26 |
Correct |
347 ms |
296 KB |
# of queries: 16511 |
27 |
Correct |
138 ms |
208 KB |
# of queries: 8295 |
28 |
Correct |
396 ms |
412 KB |
# of queries: 16956 |
29 |
Correct |
352 ms |
284 KB |
# of queries: 16937 |
30 |
Correct |
394 ms |
304 KB |
# of queries: 16956 |