답안 #722352

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
722352 2023-04-11T20:27:03 Z FatihSolak 도서관 (JOI18_library) C++17
0 / 100
44 ms 436 KB
#include <bits/stdc++.h>
#include "library.h"
using namespace std;
void Solve(int N){
	vector<int> M(N);
	auto ask = [&](vector<int> &v){
		fill(M.begin(),M.end(),0);
		for(auto u:v){
			M[u] = 1;
		}
		return Query(M);
	};
	auto ok = [&](vector<int> v,int x){
		int tmp = ask(v);
		v.push_back(x);
		return ask(v) <= tmp;
	};
	vector<int> adj[N];
	vector<bool> used(N);
	queue<int> q;
	used[0] = 1;
	q.push(0);
	q.push(0);
	while(q.size()){
		int tp = q.front();
		q.pop();
		vector<int> v;
		for(int i = 0;i<N;i++){
			if(!used[i])
				v.push_back(i);
		}
		if(v.empty())continue;
		if(!ok(v,tp))continue;
		while(v.size() > 1){
			vector<int> a;
			while(a.size() < v.size()){
				a.push_back(v.back());
				v.pop_back();
			}
			if(ok(v,tp)){
				continue;
			}
			v = a;
		}
		if(v.empty())continue;
		q.push(v[0]);
		used[v[0]] = 1;
		adj[tp].push_back(v[0]);
		adj[v[0]].push_back(tp);
	}
	vector<int> res;
	for(int i = 0;i<N;i++){
		if(adj[i].size() == 1){
			int now = i;
			while(1){
				int tmp = -1;
				if(res.size())
					tmp = res.back();
				res.push_back(now);
				if(res.size() == N)
					break;
				for(auto u:adj[now]){
					if(u != tmp){
						now = u;
						break;
					}
				}	
			}
			break;
		}
	}
	for(auto &u:res)
		u++;
	Answer(res);
}

Compilation message

library.cpp: In function 'void Solve(int)':
library.cpp:60:19: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   60 |     if(res.size() == N)
      |        ~~~~~~~~~~~^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 39 ms 320 KB # of queries: 2760
2 Correct 35 ms 436 KB # of queries: 2740
3 Correct 39 ms 320 KB # of queries: 2890
4 Correct 36 ms 308 KB # of queries: 2900
5 Correct 41 ms 324 KB # of queries: 2902
6 Correct 23 ms 320 KB # of queries: 2906
7 Correct 37 ms 316 KB # of queries: 2880
8 Correct 37 ms 320 KB # of queries: 2782
9 Correct 44 ms 320 KB # of queries: 2882
10 Correct 27 ms 316 KB # of queries: 1694
11 Incorrect 0 ms 208 KB Wrong Answer [4]
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 39 ms 320 KB # of queries: 2760
2 Correct 35 ms 436 KB # of queries: 2740
3 Correct 39 ms 320 KB # of queries: 2890
4 Correct 36 ms 308 KB # of queries: 2900
5 Correct 41 ms 324 KB # of queries: 2902
6 Correct 23 ms 320 KB # of queries: 2906
7 Correct 37 ms 316 KB # of queries: 2880
8 Correct 37 ms 320 KB # of queries: 2782
9 Correct 44 ms 320 KB # of queries: 2882
10 Correct 27 ms 316 KB # of queries: 1694
11 Incorrect 0 ms 208 KB Wrong Answer [4]
12 Halted 0 ms 0 KB -