답안 #130287

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
130287 2019-07-14T16:56:21 Z PeppaPig 사육제 (CEOI14_carnival) C++14
0 / 100
6 ms 376 KB
#include <bits/stdc++.h>

using namespace std;

const int N = 105;

int ask(vector<int> &v, int ret = 0) {
    printf("%d ", v.size());
    for(int i = 0; i < v.size() - 1; i++) printf("%d ", v[i]);
    printf("%d\n", v.back()), 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;
    }
    for(int i = 1; i <= vec.size(); i++) a[vec[i-1]] = i;
    for(int i = 1; i <= n; i++) if(!a[i]) {
        int l = 1, r = vec.size();
        while(l < r) {
            int mid = (l + r) >> 1;
            vector<int> now;
            for(int j = 0; j < mid; j++) now.emplace_back(vec[j]);
            now.emplace_back(i);
            if(ask(now) == mid) r = mid;
            else l = mid + 1;
        }
        a[i] = a[r];
    }

    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:8: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:9:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0; i < v.size() - 1; i++) printf("%d ", v[i]);
                    ~~^~~~~~~~~~~~~~
carnival.cpp: In function 'int main()':
carnival.cpp:23:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if(ask(tmp) == tmp.size()) vec = tmp;
            ~~~~~~~~~^~~~~~~~~~~~~
carnival.cpp:25:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 1; i <= vec.size(); i++) a[vec[i-1]] = i;
                    ~~^~~~~~~~~~~~~
carnival.cpp: In function 'int ask(std::vector<int>&, int)':
carnival.cpp:11: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:18:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 376 KB Integer 137 violates the range [1, 11]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 376 KB Integer 145 violates the range [1, 5]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 376 KB Integer 133 violates the range [1, 1]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 244 KB Integer 143 violates the range [1, 4]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 248 KB Integer 149 violates the range [1, 2]
2 Halted 0 ms 0 KB -