Submission #1086068

#TimeUsernameProblemLanguageResultExecution timeMemory
1086068vjudge1Carnival (CEOI14_carnival)C++17
20 / 100
40 ms600 KiB
#include <bits/stdc++.h> using namespace std; int tip[200]; int gazda[200]; int n; int prasaj(int l,int r) { cout<<r-l+1<<" "; for (int i=l;i<=r;i++) cout<<i<<" "; cout<<endl; int x; cin>>x; return x; } void najdi(int l,int r) { vector<int> grupa1,grupa2; int mid = (l+r)/2; bool vnatre[200]; memset(vnatre,0,sizeof(vnatre)); for (int i=l;i<=mid;i++) { int x = tip[i]; if (vnatre[x]==false) { vnatre[x]=true; grupa1.push_back(i); } } for (int i=mid+1;i<=r;i++) { int x = tip[i]; if (vnatre[x]==false) { vnatre[x]=true; grupa2.push_back(i); } } bool visited[200]; memset(visited,0,sizeof(visited)); for (int i=0;i<grupa1.size();i++) { for (int j=0;j<grupa2.size();j++) { int a=grupa1[i],b=grupa2[j]; if (visited[a] || visited[b]) continue; cout<<"2 "<<a<<" "<<b<<endl; int x; cin>>x; if (x==1) { visited[a]=true; visited[b]=true; int z = tip[b]; for (int q=1;q<=n;q++) { if (tip[q]==z) tip[q]=tip[a]; } } } } } int bs(int l,int r) { if (l==r) return 1; int mid = (l+r)/2; int y = prasaj(l,r); if (y==1) { for (int i=l;i<=r;i++) tip[i]=tip[l]; } else if (y==r-l+1) return y; int x = bs(l,mid) + bs(mid+1,r); if (x!=y) najdi(l,r); return y; } int stepen() { int x=1; while(x<n) x*=2; return x; } int main() { cin>>n; for (int i=1;i<=n;i++) tip[i]=i; bs(1,n); map<int,int> pr; int p = 1; for (int i=1;i<=n;i++) { int x = tip[i]; if (pr[x]==0) { pr[x]=p; p++; } } cout<<0<<" "; for (int i=1;i<=n;i++) cout<<pr[tip[i]]<<" "; cout<<endl; return 0; }

Compilation message (stderr)

carnival.cpp: In function 'void najdi(int, int)':
carnival.cpp:45:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |     for (int i=0;i<grupa1.size();i++)
      |                  ~^~~~~~~~~~~~~~
carnival.cpp:47:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |         for (int j=0;j<grupa2.size();j++)
      |                      ~^~~~~~~~~~~~~~
#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...