# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1114481 | 2024-11-19T03:09:46 Z | kokoxuya | Carnival (CEOI14_carnival) | C++17 | 29 ms | 336 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; 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); } //if (xx.size() == 0)return false; 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,-1); int currat = 0; void dfs(int currnode) { if (leader(currnode) == currnode) { ans[currnode] = currat; currat++; return; } if (ans[leader(currnode)] == -1) { dfs(leader(currnode)); } ans[currnode] = ans[leader(currnode)]; } signed main() { int t1,t2,t3,t4; int n; n = inp(); for (int a = 1; a<=n;a++) pointers[a] = a; for (int a = 2; a <=n;a++) { int hi = a-1, lo = 1,mid; bool ans = -1; while (hi >= lo) { mid = (hi+lo)/2; if (checkers(lo,mid,a)) { ans = mid; hi = mid - 1; } else { lo = mid + 1; } } if (ans != -1)merge(a,lo); } int currat = 1; for (int a = 1; a <= n; a++)dfs(a); cout << 0 << " "; for (int a = 1; a<=n;a++) { cout << ans[a] << " "; } cout << endl; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 25 ms | 336 KB | Integer 0 violates the range [1, 11] |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 27 ms | 336 KB | Integer 0 violates the range [1, 5] |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 21 ms | 336 KB | Integer 0 violates the range [1, 1] |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 24 ms | 336 KB | Integer 0 violates the range [1, 4] |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 29 ms | 336 KB | Integer 0 violates the range [1, 2] |
2 | Halted | 0 ms | 0 KB | - |