Submission #130285

#TimeUsernameProblemLanguageResultExecution timeMemory
130285PeppaPigCarnival (CEOI14_carnival)C++14
0 / 100
10 ms376 KiB
#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; } 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 (stderr)

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: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);
     ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...