//#pragma optimization_level 3
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#include"library.h"
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordset;
*/
#define fr first
#define sc second
#define vec vector
#define pb push_back
#define pii pair<int, int>
#define forn(x,y) for(int x = 1 ; x <= (int)y ; ++x)
#define all(x) (x).begin(),(x).end()
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef complex<int> point;
const int nmax = 2005;
const ll linf = 1e18;
const ll mod = 998244353;
const int inf = INT_MAX;
vec < int > A,B;
void Solve(int n){
A.resize(n);
if(n == 1)Answer({1});
for(int i = 0 ; i < n; i++){
A[i] = 1;
}
int p = 0;
A[p] = 0;
while(Query(A) > 1){
A[p] = 1;
p++;
A[p] = 0;
}
p++;
vec < int > rez;
rez.pb(p);
set < int > avb;
forn(i,n)if(i!=p)avb.insert(i);
while( avb.size() > 1){
B.clear();
for(int i : avb){
B.pb(i);
}
int l = 0, r = B.size() -1;
while( l < r){
int mid = (l+r)/2;
for(int i = 0 ; i < n; i++)A[i] = 0;
for(int i = l; i <= mid ; i++) A[B[i]-1] = 1;
int r1 = Query(A);
A[p-1] = 1;
int r2 = Query(A);
if(r1 < r2){
l = mid+1;
}else{
r = mid;
}
}
avb.erase(B[l]);
rez.pb(B[l]);
p = B[l];
}
for(int i : avb)rez.pb(i);
Answer(rez);
}
/*int main(){
fast;
}*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
40 ms |
384 KB |
# of queries: 2387 |
2 |
Correct |
45 ms |
384 KB |
# of queries: 2433 |
3 |
Correct |
46 ms |
256 KB |
# of queries: 2638 |
4 |
Correct |
43 ms |
384 KB |
# of queries: 2593 |
5 |
Correct |
42 ms |
384 KB |
# of queries: 2504 |
6 |
Correct |
31 ms |
404 KB |
# of queries: 2553 |
7 |
Correct |
31 ms |
376 KB |
# of queries: 2568 |
8 |
Correct |
41 ms |
256 KB |
# of queries: 2402 |
9 |
Correct |
35 ms |
376 KB |
# of queries: 2512 |
10 |
Correct |
26 ms |
256 KB |
# of queries: 1478 |
11 |
Incorrect |
4 ms |
256 KB |
Wrong Answer [2] |
12 |
Correct |
4 ms |
256 KB |
# of queries: 1 |
13 |
Correct |
4 ms |
256 KB |
# of queries: 4 |
14 |
Correct |
5 ms |
256 KB |
# of queries: 7 |
15 |
Correct |
6 ms |
384 KB |
# of queries: 73 |
16 |
Correct |
7 ms |
256 KB |
# of queries: 187 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
40 ms |
384 KB |
# of queries: 2387 |
2 |
Correct |
45 ms |
384 KB |
# of queries: 2433 |
3 |
Correct |
46 ms |
256 KB |
# of queries: 2638 |
4 |
Correct |
43 ms |
384 KB |
# of queries: 2593 |
5 |
Correct |
42 ms |
384 KB |
# of queries: 2504 |
6 |
Correct |
31 ms |
404 KB |
# of queries: 2553 |
7 |
Correct |
31 ms |
376 KB |
# of queries: 2568 |
8 |
Correct |
41 ms |
256 KB |
# of queries: 2402 |
9 |
Correct |
35 ms |
376 KB |
# of queries: 2512 |
10 |
Correct |
26 ms |
256 KB |
# of queries: 1478 |
11 |
Incorrect |
4 ms |
256 KB |
Wrong Answer [2] |
12 |
Correct |
4 ms |
256 KB |
# of queries: 1 |
13 |
Correct |
4 ms |
256 KB |
# of queries: 4 |
14 |
Correct |
5 ms |
256 KB |
# of queries: 7 |
15 |
Correct |
6 ms |
384 KB |
# of queries: 73 |
16 |
Correct |
7 ms |
256 KB |
# of queries: 187 |
17 |
Correct |
449 ms |
560 KB |
# of queries: 18008 |
18 |
Correct |
427 ms |
500 KB |
# of queries: 17231 |
19 |
Correct |
427 ms |
632 KB |
# of queries: 17451 |
20 |
Correct |
394 ms |
508 KB |
# of queries: 16277 |
21 |
Correct |
355 ms |
504 KB |
# of queries: 15362 |
22 |
Correct |
431 ms |
504 KB |
# of queries: 17617 |
23 |
Correct |
433 ms |
428 KB |
# of queries: 17170 |
24 |
Correct |
158 ms |
384 KB |
# of queries: 7885 |
25 |
Correct |
425 ms |
504 KB |
# of queries: 17118 |
26 |
Correct |
384 ms |
376 KB |
# of queries: 15989 |
27 |
Correct |
155 ms |
384 KB |
# of queries: 7994 |
28 |
Correct |
429 ms |
504 KB |
# of queries: 17935 |
29 |
Correct |
452 ms |
504 KB |
# of queries: 17915 |
30 |
Correct |
432 ms |
384 KB |
# of queries: 17935 |