Submission #994338

#TimeUsernameProblemLanguageResultExecution timeMemory
994338prvocisloMinerals (JOI19_minerals)C++17
75 / 100
22 ms2692 KiB
#include "minerals.h" #include <algorithm> #include <bitset> #include <cassert> #include <chrono> #include <cmath> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <random> #include <set> #include <string> #include <vector> typedef long long ll; typedef long double ld; using namespace std; vector<int> h1, h2; int c = 0; // kolko z h1 je vnutri? int lst = 0; bool other(int x) // je druhy prvok typu x vnutri? { int now = Query(x); if (now != lst) return lst = now, false; return lst = now, true; } void go(int c2) { while (c > c2) lst = Query(h1[--c]); while (c < c2) lst = Query(h1[c++]); } void solve(int l, int r, vector<int> b) { if (l == r) { Answer(h1[l - 1], b[0]); return; } int m = (l + r) / 2; go(m); vector<int> bl, br; for (int i : b) { if (other(i)) bl.push_back(i); else br.push_back(i); } solve(l, m, bl); solve(m + 1, r, br); } void Solve(int n) { for (int i = 1; i <= 2 * n; i++) { if (other(i)) h2.push_back(i); else h1.push_back(i), c++; } solve(1, n, h2); }
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...