Submission #27190

#TimeUsernameProblemLanguageResultExecution timeMemory
27190wangyenjenPark (JOI17_park)C++14
47 / 100
176 ms2120 KiB
// Author: Wang, Yen-Jen #include "park.h" #include <bits/stdc++.h> using namespace std; static int N; static int place[1400]; inline static void subtask1() { memset(place , 0 , sizeof(place)); for(int i = 0; i < N; i++) { for(int j = i + 1; j < N; j++) { place[i] = 1; place[j] = 1; if(Ask(i , j , place)) Answer(i , j); place[i] = 0; place[j] = 0; } } } inline static void subtask2() { for(int i = 0; i < N; i++) place[i] = 1; vector<int> vec; for(int i = 1; i < N - 1; i++) vec.push_back(i); stable_sort(vec.begin() , vec.end() , [&](const int x , const int y) { place[x] = 0; int t = Ask(0 , y , place); place[x] = 1; return t == 0; }); for(int i = 1; i < (int)vec.size(); i++) Answer(min(vec[i - 1] , vec[i]) , max(vec[i - 1] , vec[i])); Answer(0 , vec[0]); Answer(vec.back() , N - 1); } inline static void subtask3() { vector<int> now_lev; vector<int> vec; for(int i = 1; i < N; i++) { place[i] = 0; vec.push_back(i); } place[0] = 1; now_lev.push_back(0); while(!vec.empty()) { vector<int> vec2; vector<int> vec3; for(int x : vec) { place[x] = 1; if(Ask(0 , x , place)) vec2.push_back(x); else vec3.push_back(x); place[x] = 0; } vec = vec3; for(int x : vec2) { int lb = 0 , rb = (int)now_lev.size() - 1; place[x] = 1; while(lb < rb) { int mid = (lb + rb) >> 1; for(int i = lb; i <= mid; i++) place[now_lev[i]] = 0; int t = Ask(0 , x , place); for(int i = lb; i <= mid; i++) place[now_lev[i]] = 1; if(t) lb = mid + 1; else rb = mid; } Answer(min(now_lev[lb] , x) , max(now_lev[lb] , x)); } now_lev = vec2; } } void Detect(int T , int _N) { N = _N; if(N == 1) return; else if(N == 2) { Answer(0 , 1); return; } if(T == 1) subtask1(); else if(T == 2) subtask2(); else subtask3(); }
#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...