# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1114233 | 2024-11-18T11:59:19 Z | kokoxuya | Carnival (CEOI14_carnival) | C++14 | 50 ms | 504 KB |
#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
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 41 ms | 336 KB | Integer 0 violates the range [1, 137] |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 47 ms | 336 KB | Integer 0 violates the range [1, 145] |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2 ms | 336 KB | Time limit exceeded (wall clock) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 39 ms | 504 KB | Integer 0 violates the range [1, 143] |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 50 ms | 336 KB | Integer 0 violates the range [1, 149] |
2 | Halted | 0 ms | 0 KB | - |