Submission #48113

# Submission time Handle Problem Language Result Execution time Memory
48113 2018-05-10T05:28:34 Z rocketninja7 Library (JOI18_library) C++14
19 / 100
2000 ms 588 KB
#include <cstdio>
#include <vector>
#include "library.h"
using namespace std;

void Solve(int N)
{
    pair<int, int> neighbour[N+1];
    for(int i=1;i<N+1;i++){
        neighbour[i].first=-1;
        neighbour[i].second=-1;
    }
	for(int i=1;i<N+1;i++) {
		for(int j=i+1;j<N+1;j++){
            vector<int> M(N);
            M[i-1]=1;
            M[j-1]=1;
            if(Query(M)==1){
                if(neighbour[i].first==-1){
                    neighbour[i].first=j;
                }
                else{
                    neighbour[i].second=j;
                }
                if(neighbour[j].first==-1){
                    neighbour[j].first=i;
                }
                else{
                    neighbour[j].second=i;
                }
            }
		}
	}

	vector<int> res(N);

	for(int i=1;i<N+1;i++){
        if(neighbour[i].second==-1){
            res[0]=i;
            break;
        }
	}
	if(neighbour[res[0]].first!=-1){
        res[1]=neighbour[res[0]].first;
	}
	for(int i=2;i<N;i++){
        if(neighbour[res[i-1]].first==res[i-2]){
            res[i]=neighbour[res[i-1]].second;
        }
        else{
            res[i]=neighbour[res[i-1]].first;
        }
	}

	Answer(res);
}
# Verdict Execution time Memory Grader output
1 Correct 272 ms 248 KB Output is correct
2 Correct 309 ms 308 KB Output is correct
3 Correct 268 ms 388 KB Output is correct
4 Correct 278 ms 408 KB Output is correct
5 Correct 339 ms 412 KB Output is correct
6 Correct 312 ms 572 KB Output is correct
7 Correct 289 ms 572 KB Output is correct
8 Correct 278 ms 572 KB Output is correct
9 Correct 308 ms 572 KB Output is correct
10 Correct 128 ms 572 KB Output is correct
11 Correct 2 ms 572 KB Output is correct
12 Correct 2 ms 572 KB Output is correct
13 Correct 2 ms 572 KB Output is correct
14 Correct 2 ms 572 KB Output is correct
15 Correct 2 ms 572 KB Output is correct
16 Correct 7 ms 572 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 272 ms 248 KB Output is correct
2 Correct 309 ms 308 KB Output is correct
3 Correct 268 ms 388 KB Output is correct
4 Correct 278 ms 408 KB Output is correct
5 Correct 339 ms 412 KB Output is correct
6 Correct 312 ms 572 KB Output is correct
7 Correct 289 ms 572 KB Output is correct
8 Correct 278 ms 572 KB Output is correct
9 Correct 308 ms 572 KB Output is correct
10 Correct 128 ms 572 KB Output is correct
11 Correct 2 ms 572 KB Output is correct
12 Correct 2 ms 572 KB Output is correct
13 Correct 2 ms 572 KB Output is correct
14 Correct 2 ms 572 KB Output is correct
15 Correct 2 ms 572 KB Output is correct
16 Correct 7 ms 572 KB Output is correct
17 Execution timed out 2027 ms 588 KB Time limit exceeded
18 Halted 0 ms 0 KB -