Submission #111446

# Submission time Handle Problem Language Result Execution time Memory
111446 2019-05-15T11:41:49 Z igzi Library (JOI18_library) C++17
0 / 100
576 ms 556 KB
#include <bits/stdc++.h>
#define maxN 1005
#include "library.h"

using namespace std;

vector <int> adj[maxN];
int N;

int upit(int l,int d,int x){
vector<int> v(N);
if(x!=-1) v[x-1]=1;
for(int i=l;i<=d;i++) v[i-1]=1;
return Query(v);
}

void resi1(int l,int d,int x){
if(l==d){
    adj[x].push_back(l);
    adj[l].push_back(x);
    return;
}
int m=(l+d)/2;
if(upit(l,m,x)-upit(l,m,-1)==0) resi1(l,m,x);
else resi1(m+1,d,x);
}

void resi2(int l,int d,int x){
int m=(l+d)/2;
int tmp=upit(l,m,x)-upit(l,m,-1);
if(tmp==-1) resi2(l,m,x);
if(tmp==1) resi2(m+1,d,x);
if(tmp==0) {resi1(l,m,x); resi1(m+1,d,x);}
}

vector <int> res;

void dfs(int n,int par){
res.push_back(n);
if(adj[n][0]!=par) dfs(adj[n][0],n);
else{
    if(adj[n].size()==1) return;
    dfs(adj[n][1],n);
}
}

void Solve(int n)
{
    N=n;
	for(int i=2;i<=n;i++){
        int tmp=upit(1,i-1,i)-upit(1,i-1,-1);
        if(tmp==-1) resi2(1,i-1,i);
        if(tmp==0) resi1(1,i-1,i);
	}
	for(int i=1;i<=n;i++){
        if(adj[i].size()==1){
            dfs(i,-1);
            break;
        }
	}
	Answer(res);
}
# Verdict Execution time Memory Grader output
1 Correct 52 ms 256 KB # of queries: 2730
2 Correct 61 ms 344 KB # of queries: 2798
3 Correct 64 ms 256 KB # of queries: 2864
4 Correct 63 ms 384 KB # of queries: 2898
5 Correct 64 ms 256 KB # of queries: 2884
6 Correct 32 ms 340 KB # of queries: 2850
7 Correct 46 ms 384 KB # of queries: 2940
8 Correct 41 ms 256 KB # of queries: 2796
9 Correct 39 ms 344 KB # of queries: 2930
10 Correct 27 ms 384 KB # of queries: 1712
11 Incorrect 2 ms 384 KB Wrong Answer [4]
12 Correct 2 ms 256 KB # of queries: 2
13 Correct 3 ms 412 KB # of queries: 6
14 Correct 2 ms 384 KB # of queries: 12
15 Correct 4 ms 256 KB # of queries: 98
16 Correct 5 ms 256 KB # of queries: 230
# Verdict Execution time Memory Grader output
1 Correct 52 ms 256 KB # of queries: 2730
2 Correct 61 ms 344 KB # of queries: 2798
3 Correct 64 ms 256 KB # of queries: 2864
4 Correct 63 ms 384 KB # of queries: 2898
5 Correct 64 ms 256 KB # of queries: 2884
6 Correct 32 ms 340 KB # of queries: 2850
7 Correct 46 ms 384 KB # of queries: 2940
8 Correct 41 ms 256 KB # of queries: 2796
9 Correct 39 ms 344 KB # of queries: 2930
10 Correct 27 ms 384 KB # of queries: 1712
11 Incorrect 2 ms 384 KB Wrong Answer [4]
12 Correct 2 ms 256 KB # of queries: 2
13 Correct 3 ms 412 KB # of queries: 6
14 Correct 2 ms 384 KB # of queries: 12
15 Correct 4 ms 256 KB # of queries: 98
16 Correct 5 ms 256 KB # of queries: 230
17 Correct 543 ms 384 KB # of queries: 19364
18 Correct 429 ms 436 KB # of queries: 19016
19 Correct 521 ms 556 KB # of queries: 19160
20 Correct 388 ms 412 KB # of queries: 17832
21 Correct 410 ms 432 KB # of queries: 16854
22 Correct 576 ms 504 KB # of queries: 19274
23 Correct 470 ms 476 KB # of queries: 19252
24 Correct 159 ms 424 KB # of queries: 8846
25 Correct 482 ms 384 KB # of queries: 18830
26 Correct 369 ms 432 KB # of queries: 17506
27 Correct 133 ms 256 KB # of queries: 8832
28 Correct 484 ms 368 KB # of queries: 17954
29 Correct 446 ms 504 KB # of queries: 17934
30 Correct 554 ms 368 KB # of queries: 17954