Submission #153993

# Submission time Handle Problem Language Result Execution time Memory
153993 2019-09-17T16:23:58 Z karma Library (JOI18_library) C++14
100 / 100
546 ms 504 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);
    s.erase(find(s.begin(), s.end(), cur));
    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);
       s.erase(find(s.begin(), s.end(), cur));
    }
    Answer(ans);
}
# Verdict Execution time Memory Grader output
1 Correct 43 ms 296 KB # of queries: 2401
2 Correct 41 ms 248 KB # of queries: 2437
3 Correct 46 ms 296 KB # of queries: 2658
4 Correct 40 ms 376 KB # of queries: 2597
5 Correct 51 ms 248 KB # of queries: 2526
6 Correct 48 ms 376 KB # of queries: 2565
7 Correct 40 ms 320 KB # of queries: 2556
8 Correct 36 ms 380 KB # of queries: 2424
9 Correct 48 ms 248 KB # of queries: 2550
10 Correct 23 ms 316 KB # of queries: 1488
11 Correct 2 ms 248 KB # of queries: 0
12 Correct 2 ms 376 KB # of queries: 3
13 Correct 2 ms 376 KB # of queries: 6
14 Correct 2 ms 248 KB # of queries: 9
15 Correct 3 ms 252 KB # of queries: 79
16 Correct 5 ms 248 KB # of queries: 195
# Verdict Execution time Memory Grader output
1 Correct 43 ms 296 KB # of queries: 2401
2 Correct 41 ms 248 KB # of queries: 2437
3 Correct 46 ms 296 KB # of queries: 2658
4 Correct 40 ms 376 KB # of queries: 2597
5 Correct 51 ms 248 KB # of queries: 2526
6 Correct 48 ms 376 KB # of queries: 2565
7 Correct 40 ms 320 KB # of queries: 2556
8 Correct 36 ms 380 KB # of queries: 2424
9 Correct 48 ms 248 KB # of queries: 2550
10 Correct 23 ms 316 KB # of queries: 1488
11 Correct 2 ms 248 KB # of queries: 0
12 Correct 2 ms 376 KB # of queries: 3
13 Correct 2 ms 376 KB # of queries: 6
14 Correct 2 ms 248 KB # of queries: 9
15 Correct 3 ms 252 KB # of queries: 79
16 Correct 5 ms 248 KB # of queries: 195
17 Correct 528 ms 328 KB # of queries: 18030
18 Correct 517 ms 376 KB # of queries: 17279
19 Correct 544 ms 376 KB # of queries: 17479
20 Correct 446 ms 376 KB # of queries: 16301
21 Correct 451 ms 328 KB # of queries: 15352
22 Correct 546 ms 328 KB # of queries: 17663
23 Correct 501 ms 448 KB # of queries: 17250
24 Correct 160 ms 456 KB # of queries: 7917
25 Correct 494 ms 328 KB # of queries: 17158
26 Correct 456 ms 328 KB # of queries: 16003
27 Correct 187 ms 376 KB # of queries: 8046
28 Correct 460 ms 248 KB # of queries: 15975
29 Correct 467 ms 504 KB # of queries: 15957
30 Correct 479 ms 328 KB # of queries: 15975