Submission #918253

#TimeUsernameProblemLanguageResultExecution timeMemory
918253vjudge1Carnival (CEOI14_carnival)C++17
100 / 100
6 ms692 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long int coun(int l, int r, int ar[]){ set<int> s; for (int i = l; i <= r; i++){ s.insert(ar[i]); } return s.size(); } string getstr(int l, int r){ string ans = ""; for (int i = l; i <= r; i++){ ans += to_string(i) + " "; } return ans; } int main() { int n, res, col = 2; cin>>n; int ar[n]; ar[0] = 1; for (int i = 1; i < n; i++){ cout<<(i + 1)<<" "<<getstr(1, i + 1)<<endl; cin>>res; int c = coun(0, i - 1, ar); if (res > c){ ar[i] = col; col++; continue; } int l = 0, r = i - 1; while (true){ int mid = (l + r) / 2; string s = getstr(l + 1, mid + 1) + to_string(i + 1); cout<<(mid - l + 2)<<" "<<s<<endl; cin>>res; c = coun(l, mid, ar); if (c == res){ if (c == 1){ ar[i] = ar[l]; break; } else{ r = mid; } } else{ l = mid + 1; } } } cout<<"0 "; for (int i = 0; i < n; i++){ cout<<ar[i]<<' '; } cout<<endl; }
#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...