Submission #1114233

#TimeUsernameProblemLanguageResultExecution timeMemory
1114233kokoxuyaCarnival (CEOI14_carnival)C++14
0 / 100
50 ms504 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define pb push_back #define mp make_pair #define pii pair<int,int> #define ss second #define ff first #define piii pair<int,pii> #define debu(x) (cerr << #x << " = "<< x << "\n") #define debu2(x,y) (cerr << #x << " = "<< x << " " << #y << " = " << y << "\n") #define debu3(x,y,z) (cerr << #x << " = "<< x << " " << #y << " = " << y << " " << #z << " = " << z<< "\n") #define bitout(x,y) {\ cerr << #x << " : ";\ for (int justforbits = y; justforbits >=0; justforbits--)cout << (((1 << justforbits) & x)>=1);\ cout << "\n";\ } #define rangeout(j,rangestart,rangeend) {\ cerr << "outputting" << #j<< ":\n";\ for (int forrang = rangestart; forrang <= rangeend; forrang++)cerr << j[forrang] << " ";\ } #define c1 cerr << "Checkpoint 1! \n\n" #define c2 cerr << "Checkpoint 2! \n\n" #define c3 cerr << "Checkpoint 3! \n\n" #define c4 cerr << "Checkpoint 4! \n\n" #define defN 151 //ifstream input("output.txt"); //ofstream output("in.txt"); //#define cout output int inp() { int n; /*while (true) { if (input.fail()) { continue; } else { cerr << "can input!:)"; if (input >> n) { return n; } } }*/ cin >> n; return n; } vector<int>pointers(defN); bool checkers(int star, int en, int x) { //c3; //checks if x is the same as any other number from star to en int t1,t2; vector<int>xx; for (int a = star; a <= en; a++) { if (a == x)continue; xx.pb(a); } cout << xx.size()<< " "; for (int y : xx) { cout << y << " " ; } cout.flush(); t1 = inp(); cout << xx.size() + 1 << " "; for (int y : xx) { cout << y << " "; } cout << x << " "; cout << endl; t2 = inp(); return (t1 == t2); } int leader(int x) { if (pointers[x] == x)return x; return pointers[x] = leader(pointers[x]); } void merge(int x,int y) { pointers[leader(x)] = leader(y); } vector<int>ans(defN,0); int currat = 1; void dfs(int currnode) { if (leader(currnode) == currnode) { ans[currnode] = currat; currat++; return; } if (ans[leader(currnode)] == 0) { dfs(leader(currnode)); } ans[currnode] = ans[leader(currnode)]; } signed main() { int t1,t2,t3,t4; //cerr << "ok this works"; int n; n = inp(); //c1; for (int a = 1; a<=n;a++) pointers[a] = a; //c2; for (int a = 1; a <=n;a++) { int hi = n, lo = 1,mid; if (checkers(lo,hi,a) == 0) { //cout << "No other for " << a << "\n"; continue; } while (hi > lo) { mid = (hi+lo)/2; if (checkers(lo,mid,a)) { hi = mid; } else { lo = mid + 1; } } //cout << a << "is the same as " << lo << "\n"; merge(a,lo); } int currat = 1; dfs(1); for (int a = 1; a<=n;a++) { cout << ans[a] << " "; } cout << endl; }

Compilation message (stderr)

carnival.cpp: In function 'int main()':
carnival.cpp:123:9: warning: unused variable 't1' [-Wunused-variable]
  123 |     int t1,t2,t3,t4;
      |         ^~
carnival.cpp:123:12: warning: unused variable 't2' [-Wunused-variable]
  123 |     int t1,t2,t3,t4;
      |            ^~
carnival.cpp:123:15: warning: unused variable 't3' [-Wunused-variable]
  123 |     int t1,t2,t3,t4;
      |               ^~
carnival.cpp:123:18: warning: unused variable 't4' [-Wunused-variable]
  123 |     int t1,t2,t3,t4;
      |                  ^~
carnival.cpp:161:6: warning: unused variable 'currat' [-Wunused-variable]
  161 |  int currat = 1;
      |      ^~~~~~
#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...