답안 #549198

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
549198 2022-04-15T11:50:00 Z krit3379 도서관 (JOI18_library) C++17
100 / 100
326 ms 416 KB
#include<bits/stdc++.h>
using namespace std;
#include"library.h"
#define N 1005

bitset<N> vis;
vector<int> now,ans;

void Solve(int n){
    if(n==1){
        ans.push_back(1);
        Answer(ans);
        return ;
    }
    int i,sz,x,y,head,l,r,mid,cnt;
    now.resize(n);
    for(i=0;i<n;i++)now[i]=1;
    for(i=0;i<n;i++){
        now[i]=0;
        x=Query(now);
        now[i]=1;
        if(x==1){head=i;break;}
    }
    for(i=0;i<n;i++)now[i]=0;
    vis[head]=true;
    ans.push_back(head+1);
    for(sz=n-1;sz>0;sz--){
        l=1,r=sz;
        while(l<r){
            mid=(l+r)/2;
            for(i=0,cnt=0;i<n&&cnt<mid;i++)if(!vis[i])now[i]=1,cnt++;
            x=Query(now);
            now[head]=1;
            y=Query(now);
            now[head]=0;
            for(i=0,cnt=0;i<n&&cnt<mid;i++)if(!vis[i])now[i]=0,cnt++;
            if(x==y)r=mid;
            else l=mid+1;
        }
        for(i=0,cnt=0;i<n&&cnt<l;i++)if(!vis[i])cnt++;
        ans.push_back(i);
        head=i-1;
        vis[head]=true;
    }
    Answer(ans);
    return ;
}

Compilation message

library.cpp: In function 'void Solve(int)':
library.cpp:26:23: warning: 'head' may be used uninitialized in this function [-Wmaybe-uninitialized]
   26 |     ans.push_back(head+1);
      |                   ~~~~^~
# 결과 실행 시간 메모리 Grader output
1 Correct 31 ms 280 KB # of queries: 2387
2 Correct 28 ms 208 KB # of queries: 2433
3 Correct 32 ms 276 KB # of queries: 2638
4 Correct 34 ms 208 KB # of queries: 2593
5 Correct 31 ms 208 KB # of queries: 2504
6 Correct 35 ms 280 KB # of queries: 2553
7 Correct 33 ms 208 KB # of queries: 2568
8 Correct 29 ms 208 KB # of queries: 2402
9 Correct 30 ms 208 KB # of queries: 2512
10 Correct 13 ms 208 KB # of queries: 1478
11 Correct 0 ms 208 KB # of queries: 0
12 Correct 0 ms 208 KB # of queries: 1
13 Correct 1 ms 208 KB # of queries: 4
14 Correct 0 ms 208 KB # of queries: 7
15 Correct 1 ms 208 KB # of queries: 73
16 Correct 2 ms 208 KB # of queries: 187
# 결과 실행 시간 메모리 Grader output
1 Correct 31 ms 280 KB # of queries: 2387
2 Correct 28 ms 208 KB # of queries: 2433
3 Correct 32 ms 276 KB # of queries: 2638
4 Correct 34 ms 208 KB # of queries: 2593
5 Correct 31 ms 208 KB # of queries: 2504
6 Correct 35 ms 280 KB # of queries: 2553
7 Correct 33 ms 208 KB # of queries: 2568
8 Correct 29 ms 208 KB # of queries: 2402
9 Correct 30 ms 208 KB # of queries: 2512
10 Correct 13 ms 208 KB # of queries: 1478
11 Correct 0 ms 208 KB # of queries: 0
12 Correct 0 ms 208 KB # of queries: 1
13 Correct 1 ms 208 KB # of queries: 4
14 Correct 0 ms 208 KB # of queries: 7
15 Correct 1 ms 208 KB # of queries: 73
16 Correct 2 ms 208 KB # of queries: 187
17 Correct 240 ms 284 KB # of queries: 18008
18 Correct 256 ms 288 KB # of queries: 17231
19 Correct 192 ms 292 KB # of queries: 17451
20 Correct 305 ms 300 KB # of queries: 16277
21 Correct 264 ms 288 KB # of queries: 15362
22 Correct 256 ms 412 KB # of queries: 17617
23 Correct 229 ms 288 KB # of queries: 17170
24 Correct 121 ms 416 KB # of queries: 7885
25 Correct 227 ms 288 KB # of queries: 17118
26 Correct 268 ms 288 KB # of queries: 15989
27 Correct 92 ms 208 KB # of queries: 7994
28 Correct 276 ms 292 KB # of queries: 17935
29 Correct 326 ms 288 KB # of queries: 17915
30 Correct 271 ms 284 KB # of queries: 17935