Submission #388905

# Submission time Handle Problem Language Result Execution time Memory
388905 2021-04-13T09:36:47 Z denkendoemeer Library (JOI18_library) C++14
100 / 100
383 ms 320 KB
#include<bits/stdc++.h>
#include "library.h"
using namespace std;
void Solve(int n)
{
    vector<int>v(n,1),viz(n,0),a;
    if (n==1){
        a={1};
        Answer(a);
        return ;
    }
    int i;
    for(i=1;i<=n;i++){
        v[i-1]--;
        if (Query(v)==1){
            a.push_back(i);
            viz[i-1]=1;
            break;
        }
        v[i-1]++;
    }
    while(a.size()<n){
        vector<int>aux;
        for(i=1;i<=n;i++)
            if (viz[i-1]==0)
                aux.push_back(i);
        int st=0,dr=aux.size();
        while(dr-st>1){
            int mij=(st+dr)/2;
            fill(v.begin(),v.end(),0);
            for(i=0;i<mij;i++)
                v[aux[i]-1]++;
            int val=Query(v);
            v[a.back()-1]++;
            if (Query(v)==val)
                dr=mij;
            else
                st=mij;
        }
        a.push_back(aux[st]);
        viz[aux[st]-1]++;
    }
    Answer(a);
}

Compilation message

library.cpp: In function 'void Solve(int)':
library.cpp:22:19: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   22 |     while(a.size()<n){
      |           ~~~~~~~~^~
# Verdict Execution time Memory Grader output
1 Correct 38 ms 292 KB # of queries: 2375
2 Correct 34 ms 200 KB # of queries: 2409
3 Correct 35 ms 292 KB # of queries: 2648
4 Correct 36 ms 200 KB # of queries: 2595
5 Correct 34 ms 200 KB # of queries: 2508
6 Correct 36 ms 296 KB # of queries: 2551
7 Correct 36 ms 200 KB # of queries: 2544
8 Correct 34 ms 200 KB # of queries: 2420
9 Correct 42 ms 200 KB # of queries: 2546
10 Correct 24 ms 200 KB # of queries: 1474
11 Correct 0 ms 200 KB # of queries: 0
12 Correct 0 ms 200 KB # of queries: 1
13 Correct 0 ms 200 KB # of queries: 4
14 Correct 0 ms 200 KB # of queries: 7
15 Correct 1 ms 200 KB # of queries: 77
16 Correct 3 ms 200 KB # of queries: 183
# Verdict Execution time Memory Grader output
1 Correct 38 ms 292 KB # of queries: 2375
2 Correct 34 ms 200 KB # of queries: 2409
3 Correct 35 ms 292 KB # of queries: 2648
4 Correct 36 ms 200 KB # of queries: 2595
5 Correct 34 ms 200 KB # of queries: 2508
6 Correct 36 ms 296 KB # of queries: 2551
7 Correct 36 ms 200 KB # of queries: 2544
8 Correct 34 ms 200 KB # of queries: 2420
9 Correct 42 ms 200 KB # of queries: 2546
10 Correct 24 ms 200 KB # of queries: 1474
11 Correct 0 ms 200 KB # of queries: 0
12 Correct 0 ms 200 KB # of queries: 1
13 Correct 0 ms 200 KB # of queries: 4
14 Correct 0 ms 200 KB # of queries: 7
15 Correct 1 ms 200 KB # of queries: 77
16 Correct 3 ms 200 KB # of queries: 183
17 Correct 376 ms 296 KB # of queries: 17982
18 Correct 283 ms 320 KB # of queries: 17293
19 Correct 383 ms 200 KB # of queries: 17467
20 Correct 380 ms 300 KB # of queries: 16325
21 Correct 268 ms 320 KB # of queries: 15324
22 Correct 365 ms 304 KB # of queries: 17669
23 Correct 381 ms 308 KB # of queries: 17224
24 Correct 150 ms 200 KB # of queries: 7915
25 Correct 352 ms 200 KB # of queries: 17136
26 Correct 371 ms 300 KB # of queries: 15963
27 Correct 137 ms 300 KB # of queries: 8040
28 Correct 206 ms 304 KB # of queries: 15957
29 Correct 349 ms 292 KB # of queries: 15939
30 Correct 271 ms 200 KB # of queries: 15957