Submission #1297829

#TimeUsernameProblemLanguageResultExecution timeMemory
1297829iamsazidhMinerals (JOI19_minerals)C++20
40 / 100
53 ms70344 KiB
#include <bits/stdc++.h> #include "minerals.h" using namespace std; typedef long long ll; typedef double dl; typedef vector<int> vi; typedef vector<vector<int>> vii; typedef vector<ll> vl; typedef vector<bool> vb; typedef pair<int,int> pii; typedef pair<ll, ll> pll; #define ff first #define ss second #define all(a) a.begin(),a.end() #define gcd(a,b) __gcd(a,b) #define lcm(a,b) (a*(b/gcd(a,b))) #define file(); freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout); #define spc " " #ifdef ONLINE_JUDGE #define debarr(array) #define deb(x) #else #define debarr(array) for(int w = 0; w < array.size(); w++) cerr << #array << "-" << w << " = " << array[w] << endl; #define deb(x) cerr << #x << " = " << x << endl; #endif const double PI = acos(-1); const int MOD = 1000000007; const int inf = (2147483647); const double EPS = 1e-6; const int MAXN = 1e5+10; void Solve(int N) { int n = N*2; vector<vii> arr((N+10)*20, vii(2)); int idx = 0, pushTo = 0; int last = 0; for(int i = 1; i <= n; i++){ int now = Query(i); if(now==last){ arr[pushTo][1].push_back(i); Query(i); }else{ arr[pushTo][0].push_back(i); last = now; } } for(auto x: arr[pushTo][0]) Query(x); pushTo++; // Two group differented for(auto x: arr){ if(x[0].size()<=1) continue; int sz = x[0].size(); int m = (sz+1)/2; for(int i = 0; i < m; i++) Query(x[0][i]), arr[pushTo][0].push_back(x[0][i]); for(auto y: x[1]){ if(Query(y)==m){ arr[pushTo][1].push_back(y); }else{ arr[pushTo+1][1].push_back(y); } Query(y); } for(int i = 0; i < m; i++) Query(x[0][i]); for(int i = m; i < sz; i++){ arr[pushTo+1][0].push_back(x[0][i]); } while(arr[pushTo][0].size()!=0) pushTo++; } for(auto x: arr){ if(x[0].size()==1) Answer(x[0][0], x[1][0]); } return; }
#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...