# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
61721 | 2018-07-26T12:37:19 Z | kjp4155 | 도서관 (JOI18_library) | C++17 | 686 ms | 700 KB |
#include <cstdio> #include <vector> #include "library.h" using namespace std; #define sz(x) (int) x.size() bool vis[1050]; int L; vector<int> rans, lans; void Solve(int N) { if( N == 1 ){ lans.push_back(1); Answer(lans); return; } // find leftmost for(int i=1;i<=N;i++){ vector<int> qv; for(int j=1;j<=N;j++){ qv.push_back(1); } qv[i-1] = 0; int res1 = Query(qv); if( sz(lans) == 0 && res1 == 1 ){ lans.push_back(i); vis[i] = 1; } else if( sz(rans) == 0 && res1 == 1 ){ rans.push_back(i); vis[i] = 1; } } vector<int> qv(N); // find left while( sz(lans) + sz(rans) < N ){ int L = lans[sz(lans)-1]; int R = rans[sz(rans)-1]; int lt = 0, rt = 0; for(int k=0;k<10;k++){ for(auto& e : qv) e = 0; for(int i=1;i<=N;i++)if(!vis[i]){ if( i & (1<<k) ) qv[i-1] = 1; } bool all_zero = true, all_one = true; for(auto e : qv) if( e != 0 ) all_zero = false; for(auto e : qv) if( e != 1 ) all_one = false; if( all_zero ) continue; int res1 = Query(qv); qv[L-1] = 1; int res2 = Query(qv); qv[L-1] = 0; qv[R-1] = 1; int res3 = Query(qv); if( res1 == res2 ) lt |= (1<<k); if( res1 == res3 ) rt |= (1<<k); } lans.push_back(lt); vis[lt] = 1; if( lt != rt ){ rans.push_back(rt); vis[rt] = 1; } } for(int i=sz(rans)-1;i>=0;i--) lans.push_back(rans[i]); //for(auto e : ans ) printf("%d ",e); Answer(lans); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 40 ms | 292 KB | Output is correct |
2 | Correct | 56 ms | 440 KB | Output is correct |
3 | Correct | 77 ms | 524 KB | Output is correct |
4 | Correct | 67 ms | 524 KB | Output is correct |
5 | Correct | 37 ms | 524 KB | Output is correct |
6 | Correct | 44 ms | 524 KB | Output is correct |
7 | Correct | 59 ms | 524 KB | Output is correct |
8 | Correct | 54 ms | 524 KB | Output is correct |
9 | Correct | 39 ms | 524 KB | Output is correct |
10 | Correct | 27 ms | 524 KB | Output is correct |
11 | Correct | 2 ms | 524 KB | Output is correct |
12 | Correct | 3 ms | 524 KB | Output is correct |
13 | Correct | 3 ms | 524 KB | Output is correct |
14 | Correct | 3 ms | 532 KB | Output is correct |
15 | Correct | 7 ms | 532 KB | Output is correct |
16 | Correct | 6 ms | 544 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 40 ms | 292 KB | Output is correct |
2 | Correct | 56 ms | 440 KB | Output is correct |
3 | Correct | 77 ms | 524 KB | Output is correct |
4 | Correct | 67 ms | 524 KB | Output is correct |
5 | Correct | 37 ms | 524 KB | Output is correct |
6 | Correct | 44 ms | 524 KB | Output is correct |
7 | Correct | 59 ms | 524 KB | Output is correct |
8 | Correct | 54 ms | 524 KB | Output is correct |
9 | Correct | 39 ms | 524 KB | Output is correct |
10 | Correct | 27 ms | 524 KB | Output is correct |
11 | Correct | 2 ms | 524 KB | Output is correct |
12 | Correct | 3 ms | 524 KB | Output is correct |
13 | Correct | 3 ms | 524 KB | Output is correct |
14 | Correct | 3 ms | 532 KB | Output is correct |
15 | Correct | 7 ms | 532 KB | Output is correct |
16 | Correct | 6 ms | 544 KB | Output is correct |
17 | Correct | 686 ms | 568 KB | Output is correct |
18 | Correct | 508 ms | 700 KB | Output is correct |
19 | Correct | 618 ms | 700 KB | Output is correct |
20 | Correct | 645 ms | 700 KB | Output is correct |
21 | Correct | 408 ms | 700 KB | Output is correct |
22 | Correct | 614 ms | 700 KB | Output is correct |
23 | Correct | 685 ms | 700 KB | Output is correct |
24 | Correct | 226 ms | 700 KB | Output is correct |
25 | Correct | 580 ms | 700 KB | Output is correct |
26 | Correct | 513 ms | 700 KB | Output is correct |
27 | Correct | 205 ms | 700 KB | Output is correct |
28 | Correct | 541 ms | 700 KB | Output is correct |
29 | Correct | 674 ms | 700 KB | Output is correct |
30 | Correct | 525 ms | 700 KB | Output is correct |