답안 #550576

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
550576 2022-04-18T14:59:57 Z Pherokung 도서관 (JOI18_library) C++14
19 / 100
450 ms 304 KB
#include <cstdio>
#include <vector>
#include "library.h"
#include<bits/stdc++.h>
using namespace std;
int adj[1005][2],st=0,vis[1005];
void Solve(int n){
	vector<int> res;
	if(n == 1){
		res.push_back(1);
		Answer(res);
		return;
	}
	vector<int> M(n), K, K2;
	
	K = M; 
	for(int i=1;i<=n;i++) K[i-1] = 1;
	for(int i=1;i<=n;i++){
		K[i-1] = 0;
		if(Query(K) == 1){
			st = i;
			break;
		}
		K[i-1] = 1;
	}
	
	int pos = st,pre = -1;
	for(int i=1;i<=n;i++){
		res.push_back(pos);
		vis[pos] = 1;
		if(i == n) break;
		int be,ed = n, mid, mi = 1e9, keep = pos;
		for(int i=1;i<=n;i++)
			if(vis[i] == 0){
				be = i;
				break;
			}
		while(be <= ed){
			mid = (be+ed)/2;
			K = M;
			for(int j=1;j<=mid;j++) if(j != pre) K[j-1] = 1;
			K2 = K;
			K[pos-1] = 1, K2[pos-1] = 0;
			int A;
			if(K2 == M) A = 0;
			else A = Query(K2);
			if(Query(K) <= A){
				ed = mid - 1;
				mi = min(mi,mid);
			}
			else be = mid + 1;
		}
		pos = mi;
		pre = keep;
	}
	
	Answer(res);
}

Compilation message

library.cpp: In function 'void Solve(int)':
library.cpp:39:13: warning: 'be' may be used uninitialized in this function [-Wmaybe-uninitialized]
   39 |    mid = (be+ed)/2;
      |          ~~~^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 46 ms 208 KB # of queries: 2931
2 Correct 49 ms 300 KB # of queries: 2957
3 Correct 47 ms 208 KB # of queries: 3204
4 Correct 41 ms 208 KB # of queries: 3145
5 Correct 29 ms 208 KB # of queries: 3050
6 Correct 35 ms 208 KB # of queries: 3091
7 Correct 39 ms 208 KB # of queries: 3116
8 Correct 43 ms 208 KB # of queries: 2958
9 Correct 44 ms 208 KB # of queries: 3096
10 Correct 15 ms 304 KB # of queries: 1812
11 Correct 0 ms 208 KB # of queries: 0
12 Correct 0 ms 208 KB # of queries: 3
13 Correct 1 ms 208 KB # of queries: 8
14 Correct 1 ms 208 KB # of queries: 11
15 Correct 2 ms 208 KB # of queries: 105
16 Correct 4 ms 208 KB # of queries: 245
# 결과 실행 시간 메모리 Grader output
1 Correct 46 ms 208 KB # of queries: 2931
2 Correct 49 ms 300 KB # of queries: 2957
3 Correct 47 ms 208 KB # of queries: 3204
4 Correct 41 ms 208 KB # of queries: 3145
5 Correct 29 ms 208 KB # of queries: 3050
6 Correct 35 ms 208 KB # of queries: 3091
7 Correct 39 ms 208 KB # of queries: 3116
8 Correct 43 ms 208 KB # of queries: 2958
9 Correct 44 ms 208 KB # of queries: 3096
10 Correct 15 ms 304 KB # of queries: 1812
11 Correct 0 ms 208 KB # of queries: 0
12 Correct 0 ms 208 KB # of queries: 3
13 Correct 1 ms 208 KB # of queries: 8
14 Correct 1 ms 208 KB # of queries: 11
15 Correct 2 ms 208 KB # of queries: 105
16 Correct 4 ms 208 KB # of queries: 245
17 Runtime error 450 ms 304 KB Execution killed with signal 13
18 Halted 0 ms 0 KB -