Submission #130286

# Submission time Handle Problem Language Result Execution time Memory
130286 2019-07-14T16:56:02 Z PeppaPig Carnival (CEOI14_carnival) C++14
Compilation error
0 ms 0 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) 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) printf("%d ", v[i]);
                    ~~^~~~~~~~~~~~~~
carnival.cpp:9:36: error: expected ';' before ')' token
     for(int i = 0; i < v.size() - 1) 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);
     ~~~~~^~~~~~~~~~