답안 #413445

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
413445 2021-05-28T17:55:03 Z ritul_kr_singh 도서관 (JOI18_library) C++17
0 / 100
65 ms 404 KB
#include <bits/stdc++.h>
using namespace std;
// #define int long long
#define sp << ' ' <<
#define nl << '\n'
 
#include "library.h"
 
void Solve(int n){
	vector<array<int, 2>> e;
	vector<int> g[n], q(n), ans(n);
 
	for(int _=1; _<n; ++_){
		int low = 0, high = n-1;
		while(low < high){
			int mid = (low + high) / 2;
			int exp = mid + 1;
			for(auto &i : e) if(i[0] <= mid && i[1] <= mid) --exp;
			for(int i=0; i<n; ++i) q[i] = i <= mid;
 
			if(Query(q) == exp) low = mid + 1;
			else high = mid;
		}
 
		int x = low; low = 0, high = x-1;
 
		while(low < high){
			int mid = (low + high) / 2;
			int exp = mid + 1;
			for(auto &i : e) if(i[0] <= mid && (i[1] <= mid || i[1] == x)) --exp;
			for(int i=0; i<n; ++i) q[i] = i <= mid || i == x;
 
			if(Query(q) <= exp) high = mid;
			else low = mid + 1;
		}
      
      	assert(low < x);
 
		e.push_back({low, x});
		g[low].push_back(x);
		g[x].push_back(low);
	}
 
	int u = -1;
	for(int i=0; i<n; ++i) if((int)g[i].size() == 1) u = i;
	for(int i=0; i<n; ++i){
		ans[i] = u + 1;
		if(i == n-1) break;
		u = g[u][i && g[u][0] + 1 == ans[i-1]];
	}
 
	Answer(ans);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 38 ms 200 KB # of queries: 2793
2 Correct 49 ms 276 KB # of queries: 2772
3 Correct 45 ms 200 KB # of queries: 2917
4 Correct 50 ms 320 KB # of queries: 2923
5 Correct 65 ms 280 KB # of queries: 2909
6 Correct 42 ms 200 KB # of queries: 2915
7 Correct 53 ms 200 KB # of queries: 2929
8 Correct 37 ms 292 KB # of queries: 2799
9 Correct 43 ms 404 KB # of queries: 2922
10 Correct 30 ms 276 KB # of queries: 1707
11 Incorrect 1 ms 200 KB Wrong Answer [5]
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 38 ms 200 KB # of queries: 2793
2 Correct 49 ms 276 KB # of queries: 2772
3 Correct 45 ms 200 KB # of queries: 2917
4 Correct 50 ms 320 KB # of queries: 2923
5 Correct 65 ms 280 KB # of queries: 2909
6 Correct 42 ms 200 KB # of queries: 2915
7 Correct 53 ms 200 KB # of queries: 2929
8 Correct 37 ms 292 KB # of queries: 2799
9 Correct 43 ms 404 KB # of queries: 2922
10 Correct 30 ms 276 KB # of queries: 1707
11 Incorrect 1 ms 200 KB Wrong Answer [5]
12 Halted 0 ms 0 KB -