답안 #130281

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
130281 2019-07-14T16:49:45 Z PeppaPig 사육제 (CEOI14_carnival) C++14
0 / 100
22 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 : 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(!v.empty() && 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: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: 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:26: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:27:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 1; i <= vec.size(); i++) {
                    ~~^~~~~~~~~~~~~
carnival.cpp:29:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int j = 1; j <= vec.size(); j++) if(j != i)
                        ~~^~~~~~~~~~~~~
carnival.cpp:38:41: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                 if(!v.empty() && ask(v) == vec.size()) r = mid;
                                  ~~~~~~~^~~~~~~~~~~~~
carnival.cpp:44: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: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 21 ms 248 KB Integer 137 violates the range [1, 11]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 22 ms 248 KB Integer 145 violates the range [1, 5]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 12 ms 376 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 22 ms 248 KB Integer 143 violates the range [1, 4]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 19 ms 248 KB Integer 149 violates the range [1, 2]
2 Halted 0 ms 0 KB -