Submission #798005

#TimeUsernameProblemLanguageResultExecution timeMemory
798005vjudge1Library (JOI18_library)C++17
19 / 100
229 ms308 KiB
#include <bits/stdc++.h>
#include "library.h"
using namespace std;

void Solve(int N){
	vector<int>v(N);
	vector<int>tmp[N];
	vector<bool>vis(N, 0);

	for(int i = 0; i < N; i++){
		if(i > 0) v[i - 1] = 0;
		if(tmp[i].size() == 2) continue;
		v[i] = 1;
		v[N - 1] = 0;
		for(int j = i + 1; j < N; j++){
			if(j > i + 1) v[j - 1] = 0;
			if(tmp[j].size() == 2) continue;
			v[j] = 1;
			if(Query(v) == 1){
				tmp[i].push_back(j);
				tmp[j].push_back(i);
			}
		}
	}

	int cur = 0;
	for(int i = 0; i < N; i++){
		if(tmp[i].size() == 1){
			cur = i;
			break;
		}
	}

	vector<int>res;

	while(res.size() < N){
		res.push_back(cur + 1);
		vis[cur] = true;
		for(auto &x: tmp[cur]){
			if(!vis[x]){
				vis[x] = true;
				cur = x;
				break;
			}
		}
	}

	Answer(res);
}

Compilation message (stderr)

library.cpp: In function 'void Solve(int)':
library.cpp:36:19: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   36 |  while(res.size() < N){
      |        ~~~~~~~~~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...