답안 #630273

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
630273 2022-08-16T06:58:35 Z codr0 도서관 (JOI18_library) C++14
100 / 100
528 ms 436 KB
// Code by Parsa Eslami

#include <bits/stdc++.h>
#include "library.h"
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>

#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORR(i,a,b) for(int i=a;i>=b;i--)
#define maxm(a,b) a=max(a,b)
#define minm(a,b) a=min(a,b)
#define bit(i,j) ((j>>i)&1)
#define pb push_back
#define all(x) x.begin(),x.end()
#define SZ(x) (int)x.size()
#define err(x) cerr<<#x<<" : "<<x<<'\n'
#define dmid int mid=(r+l)/2
#define lc 2*id
#define rc 2*id+1

using namespace std;

	int query(vector<int> x){
		int t=0;
		FOR(i,0,SZ(x)-1) t+=x[i];
		return (t-Query(x));
	}

	void Solve(int n){
		vector<int> ans;
		if(n==1){
			ans.pb(1);
			Answer(ans);
			return;
		}
		FOR(j,0,n-1){
			vector<int> m(n);
			FOR(w,0,n-1) m[w]=(w!=j);
			if(query(m)==n-2){
				ans.pb(j+1);
				break;
			}
		}
		vector<int> vc2;
		FOR(i,0,n-1) if(i!=(ans.back()-1)) vc2.pb(i);
		while(!vc2.empty()){
			vector<int> vc=vc2;
			while(SZ(vc)!=1){
				int mid=SZ(vc)/2;
				vector<int> m(n);
				FOR(w,0,n-1) m[w]=0;
				FOR(j,0,mid-1) m[vc[j]]=1;
				int a1=query(m);
				m[ans.back()-1]=1;
				int a2=query(m);
				if(a2-a1==1){
					vector<int> vc0;
					FOR(j,0,mid-1) vc0.pb(vc[j]);
					vc=vc0;
				}else{
					vector<int> vc0;
					FOR(j,mid,SZ(vc)-1) vc0.pb(vc[j]);
					vc=vc0;
				}
			}
			ans.pb(vc.back()+1);
			vector<int> vc0;
			FOR(i,0,SZ(vc2)-1) if(vc2[i]!=vc.back()) vc0.pb(vc2[i]);
			vc2=vc0;
		}
		Answer(ans);
	}
# 결과 실행 시간 메모리 Grader output
1 Correct 42 ms 304 KB # of queries: 2375
2 Correct 38 ms 304 KB # of queries: 2409
3 Correct 37 ms 300 KB # of queries: 2648
4 Correct 43 ms 304 KB # of queries: 2595
5 Correct 30 ms 332 KB # of queries: 2508
6 Correct 39 ms 208 KB # of queries: 2551
7 Correct 34 ms 316 KB # of queries: 2544
8 Correct 39 ms 208 KB # of queries: 2420
9 Correct 30 ms 328 KB # of queries: 2546
10 Correct 19 ms 208 KB # of queries: 1474
11 Correct 1 ms 208 KB # of queries: 0
12 Correct 1 ms 208 KB # of queries: 1
13 Correct 0 ms 280 KB # of queries: 4
14 Correct 1 ms 248 KB # of queries: 7
15 Correct 1 ms 208 KB # of queries: 77
16 Correct 3 ms 208 KB # of queries: 183
# 결과 실행 시간 메모리 Grader output
1 Correct 42 ms 304 KB # of queries: 2375
2 Correct 38 ms 304 KB # of queries: 2409
3 Correct 37 ms 300 KB # of queries: 2648
4 Correct 43 ms 304 KB # of queries: 2595
5 Correct 30 ms 332 KB # of queries: 2508
6 Correct 39 ms 208 KB # of queries: 2551
7 Correct 34 ms 316 KB # of queries: 2544
8 Correct 39 ms 208 KB # of queries: 2420
9 Correct 30 ms 328 KB # of queries: 2546
10 Correct 19 ms 208 KB # of queries: 1474
11 Correct 1 ms 208 KB # of queries: 0
12 Correct 1 ms 208 KB # of queries: 1
13 Correct 0 ms 280 KB # of queries: 4
14 Correct 1 ms 248 KB # of queries: 7
15 Correct 1 ms 208 KB # of queries: 77
16 Correct 3 ms 208 KB # of queries: 183
17 Correct 452 ms 300 KB # of queries: 17982
18 Correct 453 ms 436 KB # of queries: 17293
19 Correct 479 ms 300 KB # of queries: 17467
20 Correct 434 ms 304 KB # of queries: 16325
21 Correct 320 ms 308 KB # of queries: 15324
22 Correct 451 ms 308 KB # of queries: 17669
23 Correct 473 ms 300 KB # of queries: 17224
24 Correct 157 ms 328 KB # of queries: 7915
25 Correct 373 ms 308 KB # of queries: 17136
26 Correct 423 ms 304 KB # of queries: 15963
27 Correct 167 ms 316 KB # of queries: 8040
28 Correct 528 ms 304 KB # of queries: 15957
29 Correct 450 ms 432 KB # of queries: 15939
30 Correct 429 ms 340 KB # of queries: 15957