답안 #798005

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
798005 2023-07-30T09:01:38 Z vjudge1 도서관 (JOI18_library) C++17
19 / 100
229 ms 308 KB
#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

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){
      |        ~~~~~~~~~~~^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 126 ms 284 KB # of queries: 12639
2 Correct 150 ms 284 KB # of queries: 13346
3 Correct 136 ms 292 KB # of queries: 14103
4 Correct 152 ms 284 KB # of queries: 14987
5 Correct 147 ms 288 KB # of queries: 14879
6 Correct 160 ms 284 KB # of queries: 14661
7 Correct 146 ms 288 KB # of queries: 14811
8 Correct 160 ms 288 KB # of queries: 14128
9 Correct 156 ms 284 KB # of queries: 14232
10 Correct 60 ms 284 KB # of queries: 5988
11 Correct 1 ms 208 KB # of queries: 0
12 Correct 0 ms 208 KB # of queries: 1
13 Correct 0 ms 208 KB # of queries: 3
14 Correct 0 ms 208 KB # of queries: 5
15 Correct 1 ms 208 KB # of queries: 79
16 Correct 3 ms 208 KB # of queries: 275
# 결과 실행 시간 메모리 Grader output
1 Correct 126 ms 284 KB # of queries: 12639
2 Correct 150 ms 284 KB # of queries: 13346
3 Correct 136 ms 292 KB # of queries: 14103
4 Correct 152 ms 284 KB # of queries: 14987
5 Correct 147 ms 288 KB # of queries: 14879
6 Correct 160 ms 284 KB # of queries: 14661
7 Correct 146 ms 288 KB # of queries: 14811
8 Correct 160 ms 288 KB # of queries: 14128
9 Correct 156 ms 284 KB # of queries: 14232
10 Correct 60 ms 284 KB # of queries: 5988
11 Correct 1 ms 208 KB # of queries: 0
12 Correct 0 ms 208 KB # of queries: 1
13 Correct 0 ms 208 KB # of queries: 3
14 Correct 0 ms 208 KB # of queries: 5
15 Correct 1 ms 208 KB # of queries: 79
16 Correct 3 ms 208 KB # of queries: 275
17 Runtime error 229 ms 308 KB Execution killed with signal 13
18 Halted 0 ms 0 KB -