Submission #155463

# Submission time Handle Problem Language Result Execution time Memory
155463 2019-09-28T13:28:19 Z Mercenary Library (JOI18_library) C++14
0 / 100
502 ms 380 KB
#include<bits/stdc++.h>
#include "library.h"
using namespace std;

void Solve(int n)
{
    vector<int> res(n);
    vector<int> ask(n , 1);
    int pre = 0;
    vector<int> p(n);
    for(int i = 0 ; i < n ; ++i)p[i] = i;
    auto del = [&](int x){
        p.erase(find(p.begin(),p.end(),x));
    };
    for(int i = 0 ; i < n ; ++i){
        ask[i] = 0;
        if(Query(ask) == 1){
            pre = i;
            break;
        }
        ask[i] = 1;
    }
    del(pre);res[0] = pre;
    for(int i = 1 ; i < n ; ++i){
        int l = 0 , h = (int)p.size() - 1;
        while(l <= h){
            fill(ask.begin(),ask.end(),0);
            int mid = l + h >> 1;
            for(int j = 0 ; j <= mid ; ++j)ask[p[j]] = 1;
            int last = Query(ask);
            ask[pre] = 1;
            if(last == Query(ask))h = mid - 1;
            else l = mid + 1;
        }
        pre = p[l];
        del(pre);
        res[i] = pre;
    }
    for(int i = 0 ; i < n ; ++i)res[i]++;
	Answer(res);
}

Compilation message

library.cpp: In function 'void Solve(int)':
library.cpp:29:25: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
             int mid = l + h >> 1;
                       ~~^~~
# Verdict Execution time Memory Grader output
1 Correct 32 ms 248 KB # of queries: 2401
2 Correct 43 ms 248 KB # of queries: 2437
3 Correct 35 ms 248 KB # of queries: 2658
4 Correct 46 ms 376 KB # of queries: 2597
5 Correct 49 ms 248 KB # of queries: 2526
6 Correct 47 ms 248 KB # of queries: 2565
7 Correct 41 ms 248 KB # of queries: 2556
8 Correct 43 ms 248 KB # of queries: 2424
9 Correct 33 ms 248 KB # of queries: 2550
10 Correct 28 ms 252 KB # of queries: 1488
11 Incorrect 2 ms 252 KB Wrong Answer [2]
12 Correct 2 ms 248 KB # of queries: 3
13 Correct 2 ms 248 KB # of queries: 6
14 Correct 2 ms 380 KB # of queries: 9
15 Correct 3 ms 252 KB # of queries: 79
16 Correct 5 ms 296 KB # of queries: 195
# Verdict Execution time Memory Grader output
1 Correct 32 ms 248 KB # of queries: 2401
2 Correct 43 ms 248 KB # of queries: 2437
3 Correct 35 ms 248 KB # of queries: 2658
4 Correct 46 ms 376 KB # of queries: 2597
5 Correct 49 ms 248 KB # of queries: 2526
6 Correct 47 ms 248 KB # of queries: 2565
7 Correct 41 ms 248 KB # of queries: 2556
8 Correct 43 ms 248 KB # of queries: 2424
9 Correct 33 ms 248 KB # of queries: 2550
10 Correct 28 ms 252 KB # of queries: 1488
11 Incorrect 2 ms 252 KB Wrong Answer [2]
12 Correct 2 ms 248 KB # of queries: 3
13 Correct 2 ms 248 KB # of queries: 6
14 Correct 2 ms 380 KB # of queries: 9
15 Correct 3 ms 252 KB # of queries: 79
16 Correct 5 ms 296 KB # of queries: 195
17 Correct 499 ms 248 KB # of queries: 18030
18 Correct 493 ms 248 KB # of queries: 17279
19 Correct 481 ms 376 KB # of queries: 17479
20 Correct 450 ms 376 KB # of queries: 16301
21 Correct 447 ms 248 KB # of queries: 15352
22 Correct 467 ms 248 KB # of queries: 17663
23 Correct 495 ms 252 KB # of queries: 17250
24 Correct 175 ms 376 KB # of queries: 7917
25 Correct 502 ms 376 KB # of queries: 17158
26 Correct 473 ms 248 KB # of queries: 16003
27 Correct 151 ms 376 KB # of queries: 8046
28 Correct 469 ms 376 KB # of queries: 15975
29 Correct 428 ms 248 KB # of queries: 15957
30 Correct 457 ms 376 KB # of queries: 15975