Submission #130296

#TimeUsernameProblemLanguageResultExecution timeMemory
130296PeppaPigCarnival (CEOI14_carnival)C++14
100 / 100
32 ms400 KiB
#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 (stderr)

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);
     ~~~~~^~~~~~~~~~
#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...