Submission #969719

#TimeUsernameProblemLanguageResultExecution timeMemory
969719penguin133Park (JOI17_park)C++17
20 / 100
413 ms1064 KiB
#include <bits/stdc++.h> using namespace std; #include "park.h" //#define int long long #define pi pair<int, int> #define pii pair<int, pi> #define fi first #define se second #ifdef _WIN32 #define getchar_unlocked _getchar_nolock #endif mt19937_64 rng(123); static int Place[1400], p2[1400]; void dnc(vector <int> shit){ if(shit.size() <= 1)return; if(shit.size() == 2){ if(shit[0] > shit[1])swap(shit[0], shit[1]); Answer(shit[0], shit[1]); return; } vector <int> nxtstuff, die[7]; int bru = shit[rng()%shit.size()]; for(int i = 0; i < (int)shit.size(); i++){ if(shit[i] == bru)continue; Place[bru] = Place[shit[i]] = 1; int a = bru, b = shit[i]; if(a > b)swap(a, b); if(Ask(a, b, Place)){ nxtstuff.push_back(shit[i]); Answer(a, b); } Place[bru] = Place[shit[i]] = 0; } for(int i = 0; i < 1400; i++)p2[i] = 0; for(auto i : shit)p2[i] = 1; for(auto i : shit){ if(i == bru)continue; bool f = 0; for(auto j : nxtstuff)if(i == j)f = 1; if(f)continue; int lo = 0, hi = (int)nxtstuff.size() - 2, tmp = (int)nxtstuff.size() - 1; while(lo <= hi){ int mid = (lo + hi) >> 1; for(int k = mid + 1; k < (int)nxtstuff.size(); k++)p2[nxtstuff[k]] = 0; int a = bru, b = i; if(a > b)swap(a, b); int res = Ask(a, b, p2); for(auto k : nxtstuff)p2[k] = 1; if(res){ tmp = mid; hi = mid - 1; } else lo = mid + 1; } die[tmp].push_back(i); } for(int i = 0; i < (int)nxtstuff.size(); i++){ die[i].push_back(nxtstuff[i]); dnc(die[i]); } } void Detect(int T, int N) { if(T == 1){ for(int i = 0; i < N; i++){ for(int j = i + 1; j < N; j++){ Place[i] = Place[j] = 1; if(Ask(i, j, Place))Answer(i, j); Place[i] = Place[j] = 0; } } return; } vector <int> lol; for(int i = 0; i < N; i++)lol.push_back(i); shuffle(lol.begin(), lol.end(), rng); dnc(lol); }
#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...