Submission #1130549

#TimeUsernameProblemLanguageResultExecution timeMemory
1130549vako_pChameleon's Love (JOI20_chameleon)C++20
0 / 100
20 ms484 KiB
#include <bits/stdc++.h> using namespace std; #define ll int #define pb push_back #include "chameleon.h" ll n; vector<ll> v[4],vv[4],q,a[2005]; bool vis[2005]; void query(ll i, ll l, ll r){ for(int j = l; j <= r; j++) q.pb(v[i][j]); } ll bins(ll i, ll j, ll i1, ll l, ll r){ q.clear(); q.pb(v[i][j]); query(i1, l, r); if(Query(q) == q.size()) return -1; l--; while(r > l + 1){ ll mid = l + (r - l) / 2; q.clear(); q.pb(v[i][j]); query(i1, l + 1, mid); if(Query(q) == q.size()) l = mid; else r = mid; } return r; } void Solve(int N) { n = N; for(int i = 1; i <= 2 * n; i++){ vv[0].pb(i); } for(int i = 1; i <= 2 * n; i++){ for(int j = i + 1; j <= 2 * n; j++){ if(Query({i, j}) == 1){ a[i].pb(j); a[j].pb(i); } } } // for(int i = 0; i < 3; i++){ // if(vv[i].size() == 0) break; // v[i].pb(vv[i][0]); // for(int j = 1; j < vv[i].size(); j++){ // v[i].pb(vv[i][j]); // if(Query(v[i]) != v[i].size()){ // vv[i + 1].pb(vv[i][j]); // v[i].pop_back(); // } // } // } // for(int i = 0; i < 3; i++){ // for(int j = 0; j < v[i].size(); j++){ // for(int k = i + 1; k < 4; k++){ // ll l = 0,sz = v[k].size(), r = sz - 1; // while(true){ // l = bins(i, j, k, l, r); // if(l == -1) break; // a[v[k][l]].pb(v[i][j]); // a[v[i][j]].pb(v[k][l++]); // } // } // } // } for(int i = 1; i <= 2 * n; i++){ if(vis[i]) continue; vis[i] = true; if(a[i].size() == 1){ vis[a[i][0]] = true; Answer(i, a[i][0]); continue; } ll x = a[i][0], y = a[i][1], z = a[i][2]; if(Query({i, x, y}) == 1) a[i].pop_back(); else if(Query({i, x, z}) == 1) a[i].erase(a[i].begin() + 1); else a[i].erase(a[i].begin()); if(vis[a[i][0]]){ vis[a[i][1]] = true; Answer(i, a[i][1]); continue; } bool ok = true; for(auto it : a[a[i][0]]){ if(it == i) continue; if(Query({i, a[i][0], it}) == 1){ vis[a[i][0]] = true; Answer(i, a[i][0]); ok = false; break; } } if(ok){ vis[a[i][1]] = true; Answer(i, a[i][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...