Submission #405536

#TimeUsernameProblemLanguageResultExecution timeMemory
405536VictorChameleon's Love (JOI20_chameleon)C++17
44 / 100
19 ms380 KiB
#include "chameleon.h" #include <bits/stdc++.h> using namespace std; #define rep(i, a, b) for (int i = a; i < (b); ++i) #define per(i, a, b) for (int i = b - 1; i >= (a); --i) #define trav(a, x) for (auto &a : x) #define all(x) x.begin(), x.end() #define sz(x) x.size() #define pb push_back #define umap unordered_map #define uset unordered_set typedef pair<int, int> ii; typedef pair<int, ii> iii; typedef vector<int> vi; typedef vector<ii> vii; typedef vector<vi> vvi; typedef long long ll; const int INF = 1'000'000'007; bitset<1001> taken; void bsearch(vi chams, int cham) { if (sz(chams) == 1) { taken[chams[0] - 1] = 1; Answer(cham, chams[0]); return; } int si = sz(chams); vi next(si >> 1); rep(i, 0, si >> 1) next[i] = chams[i]; int c1 = Query(next); next.pb(cham); int c2 = Query(next); if (c1 == c2) next.pop_back(); else { next.clear(); rep(i, si >> 1, si) next.pb(chams[i]); } bsearch(next, cham); } void Solve(int n) { int like[n * 2 + 1]; if (n <= 50) { vvi allcands(n * 2 + 1); rep(i, 1, n*2+1) { vi qvec, &cands = allcands[i]; qvec.pb(i); rep(j, 1, n * 2 + 1) { if (i == j) continue; qvec.pb(j); int colors = Query(qvec); qvec.pop_back(); if (colors == 1) cands.pb(j); } if (sz(cands) != 1) { rep(mask, 3, 7) { if (mask == 4) continue; rep(j, 0, 3) if (mask & (1 << j)) qvec.pb(cands[j]); if (Query(qvec) == 1) { rep(j, 0, 3) if (!(mask & (1 << j))) { like[i] = cands[j]; cands.erase(cands.begin() + j); } break; } qvec.pop_back(); qvec.pop_back(); } } } rep(i, 1, n * 2 + 1) { if (taken[i]) continue; vi &cands = allcands[i]; int same = cands[0]; if (sz(cands) == 2 && like[same] == i) same = cands[1]; Answer(i, same); taken[same] = 1; } } else rep(i, 0, n * 2) { if (taken[i]) continue; taken[i] = 1; vi vec; rep(j, 0, n * 2) if (!taken[j]) vec.pb(j + 1); bsearch(vec, 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...