#include <bits/stdc++.h>
#include "library.h"
using namespace std;
using ll = long long;
using ld = long double;
using db = double;
using str = string; // yay python!
using pi = pair<int,int>;
using pl = pair<ll,ll>;
using pd = pair<db,db>;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<ll>;
using vd = vector<db>;
using vs = vector<str>;
using vpi = vector<pi>;
using vpl = vector<pl>;
using vpd = vector<pd>;
// pairs
#define mp make_pair
#define f first
#define s second
// vectors
#define sz(x) (int)(x).size()
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define sor(x) sort(all(x))
#define rsz resize
#define ins insert
#define ft front()
#define bk back()
#define pf push_front
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
// loops
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)
vi x[205];
bool done[205][205];
void Solve(int n){
if(n == 1){
vi a;
a.pb(1);
Answer(a);
return;
}
vi a(n,-1);
for(int i =0;i<n;i++){
vi lol;
for(int j =0;j<n;j++){
if(j == i) continue;
vi v(n,0);
v[i] = 1;
v[j] = 1;
if(done[i][j]) continue;
done[i][j]=true;
done[j][i]=true;
if(Query(v) == 1) lol.pb(j);
}
trav(b,lol){x[i].pb(b);x[b].pb(i);}
}
int st=-1,en=-1;
for(int i =0;i<n;i++){
if(sz(x[i]) == 1){
if(st == -1) st = i;
else en = i;
}
}
set<int> vis;
a[0] = st;
vis.ins(st);
for(int i =1;i<n;i++){
for(auto j:x[a[i-1]]){
if(vis.count(j) == 0){
a[i] = j;
vis.ins(j);
break;
}
}
}
for(int i =0;i<n;i++) a[i] ++;
Answer(a);
}
/* stuff you should look for
* read the probem 3 more times in case of WA :)
* int overflow, array bounds
* special cases (n=1?)
* do smth instead of nothing and stay organized
* WRITE STUFF DOWN
* DON'T GET STUCK ON ONE APPROACH
*/
Compilation message
library.cpp: In function 'void Solve(int)':
library.cpp:76:12: warning: variable 'en' set but not used [-Wunused-but-set-variable]
76 | int st=-1,en=-1;
| ^~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
252 ms |
504 KB |
# of queries: 18336 |
2 |
Correct |
253 ms |
632 KB |
# of queries: 18145 |
3 |
Correct |
272 ms |
632 KB |
# of queries: 19900 |
4 |
Correct |
276 ms |
384 KB |
# of queries: 19900 |
5 |
Correct |
278 ms |
384 KB |
# of queries: 19900 |
6 |
Correct |
264 ms |
544 KB |
# of queries: 19900 |
7 |
Correct |
271 ms |
384 KB |
# of queries: 19900 |
8 |
Correct |
251 ms |
384 KB |
# of queries: 18528 |
9 |
Correct |
273 ms |
632 KB |
# of queries: 19701 |
10 |
Correct |
107 ms |
504 KB |
# of queries: 8256 |
11 |
Correct |
0 ms |
256 KB |
# of queries: 0 |
12 |
Correct |
0 ms |
256 KB |
# of queries: 1 |
13 |
Correct |
0 ms |
256 KB |
# of queries: 3 |
14 |
Correct |
1 ms |
256 KB |
# of queries: 6 |
15 |
Correct |
2 ms |
256 KB |
# of queries: 105 |
16 |
Correct |
5 ms |
288 KB |
# of queries: 351 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
252 ms |
504 KB |
# of queries: 18336 |
2 |
Correct |
253 ms |
632 KB |
# of queries: 18145 |
3 |
Correct |
272 ms |
632 KB |
# of queries: 19900 |
4 |
Correct |
276 ms |
384 KB |
# of queries: 19900 |
5 |
Correct |
278 ms |
384 KB |
# of queries: 19900 |
6 |
Correct |
264 ms |
544 KB |
# of queries: 19900 |
7 |
Correct |
271 ms |
384 KB |
# of queries: 19900 |
8 |
Correct |
251 ms |
384 KB |
# of queries: 18528 |
9 |
Correct |
273 ms |
632 KB |
# of queries: 19701 |
10 |
Correct |
107 ms |
504 KB |
# of queries: 8256 |
11 |
Correct |
0 ms |
256 KB |
# of queries: 0 |
12 |
Correct |
0 ms |
256 KB |
# of queries: 1 |
13 |
Correct |
0 ms |
256 KB |
# of queries: 3 |
14 |
Correct |
1 ms |
256 KB |
# of queries: 6 |
15 |
Correct |
2 ms |
256 KB |
# of queries: 105 |
16 |
Correct |
5 ms |
288 KB |
# of queries: 351 |
17 |
Runtime error |
5 ms |
512 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
18 |
Halted |
0 ms |
0 KB |
- |