Submission #153994

# Submission time Handle Problem Language Result Execution time Memory
153994 2019-09-17T16:27:04 Z karma Library (JOI18_library) C++14
100 / 100
538 ms 456 KB
#include<bits/stdc++.h>
#include "library.h"
#define pb      emplace_back
#define ll      long long

using namespace std;

const int N = int(2e3) + 7;

vector<int> m, ans, s;
int low, high, mid, cur;

void Solve(int n) {
    if(n == 1) {Answer({1}); return;}
    m.resize(n, 1); s.resize(n);
    for(int i = 0; i < n; ++i) {
       m[i] = 0;
       if(Query(m) == 1) {cur = i; break;}
       m[i] = 1;
    }
    iota(s.begin(), s.end(), 0);
    ans.pb(cur + 1);
    swap(s[cur], s[s.size() - 1]);
    s.pop_back();
    while(s.size()) {
       low = 0, high = s.size() - 1;
       while(low <= high) {
           mid = (low + high) >> 1;
           fill(m.begin(), m.end(), 0);
           for(int i = 0; i <= mid; ++i) m[s[i]] = 1;
           int res = Query(m);
           m[cur] = 1;
           if(res == Query(m)) high = mid - 1;
           else low = mid + 1;
       }
       cur = s[low];
       ans.pb(cur + 1);
       swap(s[low], s[s.size() - 1]);
       s.pop_back();
    }
    Answer(ans);
}
# Verdict Execution time Memory Grader output
1 Correct 37 ms 248 KB # of queries: 2409
2 Correct 43 ms 376 KB # of queries: 2445
3 Correct 49 ms 376 KB # of queries: 2666
4 Correct 51 ms 400 KB # of queries: 2607
5 Correct 44 ms 400 KB # of queries: 2534
6 Correct 48 ms 376 KB # of queries: 2543
7 Correct 46 ms 376 KB # of queries: 2554
8 Correct 44 ms 248 KB # of queries: 2432
9 Correct 43 ms 376 KB # of queries: 2552
10 Correct 30 ms 244 KB # of queries: 1494
11 Correct 2 ms 296 KB # of queries: 0
12 Correct 2 ms 376 KB # of queries: 3
13 Correct 2 ms 248 KB # of queries: 6
14 Correct 2 ms 248 KB # of queries: 11
15 Correct 3 ms 376 KB # of queries: 79
16 Correct 5 ms 376 KB # of queries: 197
# Verdict Execution time Memory Grader output
1 Correct 37 ms 248 KB # of queries: 2409
2 Correct 43 ms 376 KB # of queries: 2445
3 Correct 49 ms 376 KB # of queries: 2666
4 Correct 51 ms 400 KB # of queries: 2607
5 Correct 44 ms 400 KB # of queries: 2534
6 Correct 48 ms 376 KB # of queries: 2543
7 Correct 46 ms 376 KB # of queries: 2554
8 Correct 44 ms 248 KB # of queries: 2432
9 Correct 43 ms 376 KB # of queries: 2552
10 Correct 30 ms 244 KB # of queries: 1494
11 Correct 2 ms 296 KB # of queries: 0
12 Correct 2 ms 376 KB # of queries: 3
13 Correct 2 ms 248 KB # of queries: 6
14 Correct 2 ms 248 KB # of queries: 11
15 Correct 3 ms 376 KB # of queries: 79
16 Correct 5 ms 376 KB # of queries: 197
17 Correct 538 ms 376 KB # of queries: 18020
18 Correct 526 ms 376 KB # of queries: 17283
19 Correct 518 ms 324 KB # of queries: 17501
20 Correct 432 ms 248 KB # of queries: 16313
21 Correct 391 ms 380 KB # of queries: 15308
22 Correct 499 ms 452 KB # of queries: 17669
23 Correct 499 ms 456 KB # of queries: 17234
24 Correct 161 ms 376 KB # of queries: 7893
25 Correct 497 ms 320 KB # of queries: 17138
26 Correct 461 ms 320 KB # of queries: 16037
27 Correct 144 ms 376 KB # of queries: 8038
28 Correct 513 ms 428 KB # of queries: 17571
29 Correct 506 ms 448 KB # of queries: 17529
30 Correct 506 ms 376 KB # of queries: 17571