답안 #549190

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
549190 2022-04-15T11:40:29 Z krit3379 도서관 (JOI18_library) C++17
0 / 100
37 ms 336 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){
    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:35:24: warning: left operand of comma operator has no effect [-Wunused-value]
   35 |         for(i=0,cnt=0;i<n,cnt<l;i++)if(!vis[i])cnt++;
      |                       ~^~
library.cpp:21:23: warning: 'head' may be used uninitialized in this function [-Wmaybe-uninitialized]
   21 |     ans.push_back(head+1);
      |                   ~~~~^~
# 결과 실행 시간 메모리 Grader output
1 Correct 34 ms 208 KB # of queries: 2387
2 Correct 34 ms 276 KB # of queries: 2433
3 Correct 33 ms 276 KB # of queries: 2638
4 Correct 28 ms 280 KB # of queries: 2593
5 Correct 20 ms 316 KB # of queries: 2504
6 Correct 29 ms 208 KB # of queries: 2553
7 Correct 34 ms 208 KB # of queries: 2568
8 Correct 34 ms 276 KB # of queries: 2402
9 Correct 37 ms 300 KB # of queries: 2512
10 Correct 12 ms 208 KB # of queries: 1478
11 Runtime error 1 ms 336 KB Execution killed with signal 11
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 34 ms 208 KB # of queries: 2387
2 Correct 34 ms 276 KB # of queries: 2433
3 Correct 33 ms 276 KB # of queries: 2638
4 Correct 28 ms 280 KB # of queries: 2593
5 Correct 20 ms 316 KB # of queries: 2504
6 Correct 29 ms 208 KB # of queries: 2553
7 Correct 34 ms 208 KB # of queries: 2568
8 Correct 34 ms 276 KB # of queries: 2402
9 Correct 37 ms 300 KB # of queries: 2512
10 Correct 12 ms 208 KB # of queries: 1478
11 Runtime error 1 ms 336 KB Execution killed with signal 11
12 Halted 0 ms 0 KB -