Submission #267131

# Submission time Handle Problem Language Result Execution time Memory
267131 2020-08-15T21:19:32 Z DavidDamian Library (JOI18_library) C++11
19 / 100
2000 ms 384 KB
#include<bits/stdc++.h>
#include "library.h"
///Subtask 1
///Discover from the edges (start and end)
using namespace std;

void Solve(int N)
{
	vector<int> full(N,1);
	vector<int> Empty(N,0);
	vector<int> ans(N,0);
	vector<int> found(N+1,0);
	if(N==1){
        Answer(full);
        return;
	}
	int L=0;
	int id_L=0;
	int id_R=N-1;
	for(int n=1;n<N;n++){
        for(int i=1;i<=N;i++){
            if(found[i]) continue;
            full[i-1]=0;
            int cost=Query(full);
            if(cost==1){
                if(L==0){
                    L=i;
                    ans[0]=i;
                    id_L++;
                }
                else{
                    Empty[L-1]=1;
                    Empty[i-1]=1;
                    cost=Query(Empty);
                    if(cost==1){
                        ans[id_L++]=i;
                        L=i;
                    }
                    else{
                        ans[id_R--]=i;
                    }
                    Empty[L-1]=0;
                    Empty[i-1]=0;
                }
                found[i]=1;
                break;
            }
            else full[i-1]=1;
        }
	}
	int remain=0;
	for(int i=1;i<=N;i++){
        if(!found[i]) remain=i;
	}
	for(int i=0;i<N;i++){
        if(ans[i]==0) ans[i]=remain;
	}
	Answer(ans);
}
# Verdict Execution time Memory Grader output
1 Correct 137 ms 256 KB # of queries: 9359
2 Correct 120 ms 256 KB # of queries: 9606
3 Correct 109 ms 256 KB # of queries: 10013
4 Correct 156 ms 256 KB # of queries: 10380
5 Correct 167 ms 256 KB # of queries: 9692
6 Correct 126 ms 384 KB # of queries: 9806
7 Correct 139 ms 256 KB # of queries: 10059
8 Correct 134 ms 256 KB # of queries: 9360
9 Correct 139 ms 256 KB # of queries: 9984
10 Correct 59 ms 256 KB # of queries: 4269
11 Correct 0 ms 256 KB # of queries: 0
12 Correct 0 ms 256 KB # of queries: 1
13 Correct 1 ms 256 KB # of queries: 4
14 Correct 1 ms 360 KB # of queries: 6
15 Correct 2 ms 256 KB # of queries: 62
16 Correct 5 ms 256 KB # of queries: 203
# Verdict Execution time Memory Grader output
1 Correct 137 ms 256 KB # of queries: 9359
2 Correct 120 ms 256 KB # of queries: 9606
3 Correct 109 ms 256 KB # of queries: 10013
4 Correct 156 ms 256 KB # of queries: 10380
5 Correct 167 ms 256 KB # of queries: 9692
6 Correct 126 ms 384 KB # of queries: 9806
7 Correct 139 ms 256 KB # of queries: 10059
8 Correct 134 ms 256 KB # of queries: 9360
9 Correct 139 ms 256 KB # of queries: 9984
10 Correct 59 ms 256 KB # of queries: 4269
11 Correct 0 ms 256 KB # of queries: 0
12 Correct 0 ms 256 KB # of queries: 1
13 Correct 1 ms 256 KB # of queries: 4
14 Correct 1 ms 360 KB # of queries: 6
15 Correct 2 ms 256 KB # of queries: 62
16 Correct 5 ms 256 KB # of queries: 203
17 Execution timed out 3063 ms 384 KB Time limit exceeded
18 Halted 0 ms 0 KB -