답안 #130296

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
130296 2019-07-14T17:07:16 Z PeppaPig 사육제 (CEOI14_carnival) C++14
100 / 100
32 ms 400 KB
#include <bits/stdc++.h>
 
using namespace std;
 
const int N = 155;
 
int ask(vector<int> &v, int ret = 0) {
    if(v.empty()) return 0;
    printf("%d ", v.size());
    for(int i : v) printf("%d ", i);
    printf("\n"), fflush(stdout);
    scanf("%d", &ret);
    return ret;
}
 
int n, a[N];
 
int main() {
    scanf("%d", &n);
    vector<int> vec = {1};
    for(int i = 2; i <= n; i++) {
        vector<int> tmp = vec;
        tmp.emplace_back(i);
        if(ask(tmp) == tmp.size()) vec = tmp;
    }
    int cnt = n;
    for(int i = 1; i <= vec.size(); i++) a[vec[i-1]] = i, --cnt;
    for(int i = 1; i <= vec.size(); i++) {
        vector<int> now;
        for(int j = 1; j <= vec.size(); j++) if(j != i)
            now.emplace_back(vec[j-1]);
        while(cnt) {
            int l = 1, r = n;
            while(l < r) {
                int mid = (l + r) >> 1;
                vector<int> v = now;
                for(int j = 1; j <= mid; j++) if(!a[j] && j != vec[i - 1])
                    v.emplace_back(j);
                if(ask(v) == vec.size()) r = mid;
                else l = mid + 1;
            }
            vector<int> v = now;
            for(int j = 1; j <= r; j++) if(!a[j])
                v.emplace_back(j);
            if(ask(v) == vec.size()) a[r] = i, --cnt;
            else break;
        }
    }
    printf("0 ");
    for(int i = 1; i <= n; i++) printf("%d ", a[i]);
    printf("\n"), fflush(stdout);
 
    return 0;
}

Compilation message

carnival.cpp: In function 'int ask(std::vector<int>&, int)':
carnival.cpp:9:27: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::vector<int>::size_type {aka long unsigned int}' [-Wformat=]
     printf("%d ", v.size());
                   ~~~~~~~~^
carnival.cpp: In function 'int main()':
carnival.cpp:24:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if(ask(tmp) == tmp.size()) vec = tmp;
            ~~~~~~~~~^~~~~~~~~~~~~
carnival.cpp:27:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 1; i <= vec.size(); i++) a[vec[i-1]] = i, --cnt;
                    ~~^~~~~~~~~~~~~
carnival.cpp:28:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 1; i <= vec.size(); i++) {
                    ~~^~~~~~~~~~~~~
carnival.cpp:30:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int j = 1; j <= vec.size(); j++) if(j != i)
                        ~~^~~~~~~~~~~~~
carnival.cpp:39:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                 if(ask(v) == vec.size()) r = mid;
                    ~~~~~~~^~~~~~~~~~~~~
carnival.cpp:45:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             if(ask(v) == vec.size()) a[r] = i, --cnt;
                ~~~~~~~^~~~~~~~~~~~~
carnival.cpp: In function 'int ask(std::vector<int>&, int)':
carnival.cpp:12:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &ret);
     ~~~~~^~~~~~~~~~~~
carnival.cpp: In function 'int main()':
carnival.cpp:19:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 22 ms 376 KB Output is correct
2 Correct 21 ms 312 KB Output is correct
3 Correct 24 ms 248 KB Output is correct
4 Correct 18 ms 296 KB Output is correct
5 Correct 17 ms 252 KB Output is correct
6 Correct 16 ms 376 KB Output is correct
7 Correct 13 ms 312 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 20 ms 376 KB Output is correct
2 Correct 24 ms 376 KB Output is correct
3 Correct 19 ms 252 KB Output is correct
4 Correct 16 ms 316 KB Output is correct
5 Correct 11 ms 248 KB Output is correct
6 Correct 10 ms 248 KB Output is correct
7 Correct 21 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 376 KB Output is correct
2 Correct 32 ms 376 KB Output is correct
3 Correct 25 ms 376 KB Output is correct
4 Correct 23 ms 248 KB Output is correct
5 Correct 11 ms 316 KB Output is correct
6 Correct 19 ms 248 KB Output is correct
7 Correct 22 ms 400 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 248 KB Output is correct
2 Correct 23 ms 248 KB Output is correct
3 Correct 30 ms 376 KB Output is correct
4 Correct 15 ms 400 KB Output is correct
5 Correct 12 ms 316 KB Output is correct
6 Correct 15 ms 376 KB Output is correct
7 Correct 23 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 20 ms 376 KB Output is correct
2 Correct 21 ms 248 KB Output is correct
3 Correct 19 ms 320 KB Output is correct
4 Correct 26 ms 376 KB Output is correct
5 Correct 10 ms 312 KB Output is correct
6 Correct 8 ms 316 KB Output is correct
7 Correct 21 ms 316 KB Output is correct