Submission #46196

#TimeUsernameProblemLanguageResultExecution timeMemory
46196ikura355Carnival (CEOI14_carnival)C++14
100 / 100
15 ms576 KiB
#include<bits/stdc++.h> using namespace std; const int maxn = 150 + 5; int n; int c, rep[maxn], com[maxn]; vector<int> p, act; int ask() { printf("%d",act.size()); for(auto x : act) printf(" %d",x); printf("\n"); fflush(stdout); int ret; scanf("%d",&ret); return ret; } int noey(int l, int r, int x) { act.clear(); for(int i=l;i<=r;i++) act.push_back(p[i]); int old = ask(); act.push_back(x); int boy = ask(); return old == boy; } void connect(int x) { p.clear(); for(int i=1;i<=c;i++) p.push_back(rep[i]); //1. new component if(c==0 || !noey(0,p.size()-1,x)) { rep[++c] = x; com[x] = c; return ; } //2. connecting int l = 0, r = p.size()-1; while(l<r) { int mid = (l+r)/2; if(noey(l,mid,x)) r = mid; else l = mid+1; } com[x] = com[p[l]]; } int main() { scanf("%d",&n); for(int x=1;x<=n;x++) connect(x); printf("0"); for(int x=1;x<=n;x++) printf(" %d",com[x]); fflush(stdout); }

Compilation message (stderr)

carnival.cpp: In function 'int ask()':
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",act.size());
                 ~~~~~~~~~~^
carnival.cpp:12:19: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     int ret; scanf("%d",&ret);
              ~~~~~^~~~~~~~~~~
carnival.cpp: In function 'int main()':
carnival.cpp:42:7: 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...