답안 #155467

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
155467 2019-09-28T13:38:03 Z Mercenary 도서관 (JOI18_library) C++14
100 / 100
552 ms 380 KB
#include<bits/stdc++.h>
#include "library.h"
using namespace std;

void Solve(int n)
{
    vector<int> res(n , 1);
    if(n == 1){
    	Answer(res);
		return;
    }
    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){
            for(int j = 0 ; j < n ; ++j)ask[j] = 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:34:25: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
             int mid = l + h >> 1;
                       ~~^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 41 ms 248 KB # of queries: 2401
2 Correct 48 ms 248 KB # of queries: 2437
3 Correct 50 ms 248 KB # of queries: 2658
4 Correct 45 ms 248 KB # of queries: 2597
5 Correct 34 ms 380 KB # of queries: 2526
6 Correct 50 ms 248 KB # of queries: 2565
7 Correct 48 ms 248 KB # of queries: 2556
8 Correct 33 ms 248 KB # of queries: 2424
9 Correct 44 ms 376 KB # of queries: 2550
10 Correct 28 ms 376 KB # of queries: 1488
11 Correct 1 ms 376 KB # of queries: 0
12 Correct 2 ms 252 KB # of queries: 3
13 Correct 2 ms 376 KB # of queries: 6
14 Correct 2 ms 376 KB # of queries: 9
15 Correct 3 ms 376 KB # of queries: 79
16 Correct 6 ms 248 KB # of queries: 195
# 결과 실행 시간 메모리 Grader output
1 Correct 41 ms 248 KB # of queries: 2401
2 Correct 48 ms 248 KB # of queries: 2437
3 Correct 50 ms 248 KB # of queries: 2658
4 Correct 45 ms 248 KB # of queries: 2597
5 Correct 34 ms 380 KB # of queries: 2526
6 Correct 50 ms 248 KB # of queries: 2565
7 Correct 48 ms 248 KB # of queries: 2556
8 Correct 33 ms 248 KB # of queries: 2424
9 Correct 44 ms 376 KB # of queries: 2550
10 Correct 28 ms 376 KB # of queries: 1488
11 Correct 1 ms 376 KB # of queries: 0
12 Correct 2 ms 252 KB # of queries: 3
13 Correct 2 ms 376 KB # of queries: 6
14 Correct 2 ms 376 KB # of queries: 9
15 Correct 3 ms 376 KB # of queries: 79
16 Correct 6 ms 248 KB # of queries: 195
17 Correct 552 ms 376 KB # of queries: 18030
18 Correct 496 ms 376 KB # of queries: 17279
19 Correct 516 ms 248 KB # of queries: 17479
20 Correct 486 ms 376 KB # of queries: 16301
21 Correct 431 ms 252 KB # of queries: 15352
22 Correct 539 ms 376 KB # of queries: 17663
23 Correct 522 ms 248 KB # of queries: 17250
24 Correct 193 ms 380 KB # of queries: 7917
25 Correct 489 ms 376 KB # of queries: 17158
26 Correct 449 ms 376 KB # of queries: 16003
27 Correct 142 ms 248 KB # of queries: 8046
28 Correct 463 ms 376 KB # of queries: 15975
29 Correct 463 ms 248 KB # of queries: 15957
30 Correct 477 ms 248 KB # of queries: 15975