Submission #553208

#TimeUsernameProblemLanguageResultExecution timeMemory
553208Killer2501Chameleon's Love (JOI20_chameleon)C++14
4 / 100
30 ms2768 KiB
#include "chameleon.h" #include <bits/stdc++.h> #define ll long long #define ld long double #define ull unsigned long long #define pb push_back #define pll pair<int, pii> #define pii pair<int, int> #define fi first #define se second using namespace std; const int N = 1e5+2; const int M = 60; const int mod = 1e9+7; const ll base = 1e6; const ll inf = 1e9; int n, m, b[N], a[N], k, t, d[N], cnt, par[N], f[N]; ll ans; vector<int> adj[N]; bool vis[N], ok; bool ask(vector<int> vi, int x) { if(vi.empty())return false; vi.pb(x); return Query(vi) != (int) vi.size(); } void Solve(int n) { n *= 2; for(int i = 1; i <= n; i ++) { vector<int> group[2]; fill_n(a, i, -1); for(int j = 1; j < i; j ++) { if(a[j] == -1)a[j] = 0; for(int p: adj[j])a[p] = a[j]^1; group[a[j]].pb(j); } for(int j = 0; j < 2; j ++) { while(ask(group[j], i)) { int l = 1, r = group[j].size(); while(l <= r) { int mid = (l+r)>>1; if(ask(vector<int>(group[j].begin(), group[j].begin()+mid), i))r = mid-1; else l = mid+1; } adj[group[j][l-1]].pb(i); adj[i].pb(group[j][l-1]); group[j].erase(group[j].begin(), group[j].begin()+l); } } } for(int i = 1; i <= n; i ++) { if(adj[i].size() == 1) { b[i] = adj[i][0]; continue; } for(int l = 0; l < 3; l ++) { for(int r = l+1; r < 3; r ++) { if(Query({i, adj[i][l], adj[i][r]}) == 3) { b[i] = adj[i][3^l^r]; break; } } if(b[i])break; } } for(int i = 1; i <= n; i ++) { if(b[i] > i)Answer(i, b[i]); } }
#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...