Submission #344024

# Submission time Handle Problem Language Result Execution time Memory
344024 2021-01-05T04:50:53 Z tengiz05 Library (JOI18_library) C++17
0 / 100
321 ms 492 KB
#include <bits/stdc++.h>
#include "library.h"
//~ #include "grader.cpp"
using namespace std;
void Solve(int n){
	vector<vector<int>> v(n);
	for(int i=0;i<n;i++){
		vector<int> ask(n, 0);
		ask[i] = 1;
		for(int j=i+1;j<n;j++){
			ask[j] = 1;
			if(Query(ask) == 1)v[i].push_back(j), v[j].push_back(i);
			ask[j] = 0;
		}
	}
	//~ for(int i=0;i<n;i++){for(auto x : v[i])cout << x << ' ';cout << '\n';}
	vector<bool> used(n);
	vector<int> ans;
	int u=-1;
	for(int i=0;i<n;i++){
		if(v[i].size() == 1){
			u = i;break;
		}
	}
	assert(u != -1);
	while(true){
		bool ch = false;
		used[u] = true;
		ans.push_back(u+1);
		for(auto to : v[u]){
			if(!used[to]){
				ch=true;
				u=to;
			}
		}if(!ch)break;
	}
	Answer(ans);
	return;
}

/*

5
4 2 5 3 1

*/
# Verdict Execution time Memory Grader output
1 Correct 301 ms 364 KB # of queries: 18336
2 Correct 217 ms 492 KB # of queries: 18145
3 Correct 311 ms 364 KB # of queries: 19900
4 Correct 289 ms 364 KB # of queries: 19900
5 Correct 270 ms 364 KB # of queries: 19900
6 Correct 321 ms 384 KB # of queries: 19900
7 Correct 244 ms 380 KB # of queries: 19900
8 Correct 184 ms 492 KB # of queries: 18528
9 Correct 243 ms 492 KB # of queries: 19701
10 Correct 123 ms 492 KB # of queries: 8256
11 Runtime error 1 ms 492 KB Execution killed with signal 6 (could be triggered by violating memory limits)
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 301 ms 364 KB # of queries: 18336
2 Correct 217 ms 492 KB # of queries: 18145
3 Correct 311 ms 364 KB # of queries: 19900
4 Correct 289 ms 364 KB # of queries: 19900
5 Correct 270 ms 364 KB # of queries: 19900
6 Correct 321 ms 384 KB # of queries: 19900
7 Correct 244 ms 380 KB # of queries: 19900
8 Correct 184 ms 492 KB # of queries: 18528
9 Correct 243 ms 492 KB # of queries: 19701
10 Correct 123 ms 492 KB # of queries: 8256
11 Runtime error 1 ms 492 KB Execution killed with signal 6 (could be triggered by violating memory limits)
12 Halted 0 ms 0 KB -