Submission #26171

#TimeUsernameProblemLanguageResultExecution timeMemory
26171ruhanhabib39Carnival (CEOI14_carnival)C++14
100 / 100
16 ms2020 KiB
#include <bits/stdc++.h> using namespace std; int N; vector<int> gp; int res[150 + 10]; int query(vector<int> v) { printf("%d", (int)v.size()); for(int i : v) { printf(" %d", i); } printf("\n"); fflush(stdout); int k; scanf("%d", &k); return k; } int main() { scanf("%d", &N); gp.push_back(1); for(int i = 2; i <= N; i++) { gp.push_back(i); if(query(gp) != gp.size()) { gp.pop_back(); } } for(int i = 0; i < (int)gp.size(); i++) { res[gp[i]] = i+1; } for(int i = 1; i <= N; i++) { if(res[i]) continue; int lo = 1, hi = gp.size(); while(lo < hi) { int m = (lo + hi) / 2; auto q = vector<int>(gp.begin(), gp.begin() + m); q.push_back(i); if(query(q) < q.size()) hi = m; else lo = m+1; } res[i] = lo; } printf("0"); for(int i = 1; i <= N; i++) { printf(" %d", res[i]); } printf("\n"); fflush(stdout); }

Compilation message (stderr)

carnival.cpp: In function 'int main()':
carnival.cpp:24:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
       if(query(gp) != gp.size()) {
                    ^
carnival.cpp:38:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
          if(query(q) < q.size()) hi = m;
                      ^
carnival.cpp: In function 'int query(std::vector<int>)':
carnival.cpp:15:26: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    int k; scanf("%d", &k);
                          ^
carnival.cpp: In function 'int main()':
carnival.cpp:20:19: 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...