Submission #1155020

#TimeUsernameProblemLanguageResultExecution timeMemory
1155020steveonalexRail (IOI14_rail)C++17
0 / 100
33 ms584 KiB
/* ________ ___ ________ ________ ________ ___ ________ ________ ________ |\ ____\|\ \|\ ____\|\ __ \ |\ ___ \|\ \|\ ____\|\ ____\|\ __ \ \ \ \___|\ \ \ \ \___|\ \ \|\ \ \ \ \\ \ \ \ \ \ \___|\ \ \___|\ \ \|\ \ \ \ \ __\ \ \ \ \ __\ \ __ \ \ \ \\ \ \ \ \ \ \ __\ \ \ __\ \ __ \ \ \ \|\ \ \ \ \ \|\ \ \ \ \ \ \ \ \\ \ \ \ \ \ \|\ \ \ \|\ \ \ \ \ \ \ \_______\ \__\ \_______\ \__\ \__\ \ \__\\ \__\ \__\ \_______\ \_______\ \__\ \__\ \|_______|\|__|\|_______|\|__|\|__| \|__| \|__|\|__|\|_______|\|_______|\|__|\|__| ________ ________ ________ ________ ___ ___ ________ _________ ___ ________ ________ |\ __ \|\ __ \|\ __ \|\ ___ \|\ \|\ \|\ ____\\___ ___\\ \|\ __ \|\ ___ \ \ \ \|\ \ \ \|\ \ \ \|\ \ \ \_|\ \ \ \\\ \ \ \___\|___ \ \_\ \ \ \ \|\ \ \ \\ \ \ \ \ ____\ \ _ _\ \ \\\ \ \ \ \\ \ \ \\\ \ \ \ \ \ \ \ \ \ \ \\\ \ \ \\ \ \ \ \ \___|\ \ \\ \\ \ \\\ \ \ \_\\ \ \ \\\ \ \ \____ \ \ \ \ \ \ \ \\\ \ \ \\ \ \ \ \__\ \ \__\\ _\\ \_______\ \_______\ \_______\ \_______\ \ \__\ \ \__\ \_______\ \__\\ \__\ \|__| \|__|\|__|\|_______|\|_______|\|_______|\|_______| \|__| \|__|\|_______|\|__| \|__| Written by: giga nigga */ // #include "largest.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; #define MASK(i) (1ULL << (i)) #define GETBIT(mask, i) (((mask) >> (i)) & 1) #define ALL(v) (v).begin(), (v).end() ll max(ll a, ll b){return (a > b) ? a : b;} ll min(ll a, ll b){return (a < b) ? a : b;} ll gcd(ll a, ll b){return __gcd(a, b);} ll lcm(ll a, ll b){return a / gcd(a, b) * b;} ll LASTBIT(ll mask){return (mask) & (-mask);} int pop_cnt(ull mask){return __builtin_popcountll(mask);} int ctz(ull mask){return __builtin_ctzll(mask);} int logOf(ull mask){return 63 - __builtin_clzll(mask);} mt19937_64 rng(chrono::high_resolution_clock::now().time_since_epoch().count()); // mt19937_64 rng(1); ll rngesus(ll l, ll r){return l + (ull) rng() % (r - l + 1);} double rngesus_d(double l, double r){ double wow = (double) ((ull) rng()) / ((ull)(0-1)); return wow * (r - l) + l; } template <class T1, class T2> bool maximize(T1 &a, T2 b){ if (a < b) {a = b; return true;} return false; } template <class T1, class T2> bool minimize(T1 &a, T2 b){ if (a > b) {a = b; return true;} return false; } template <class T> void printArr(T container, string separator = " ", string finish = "\n", ostream &out = cout){ for(auto item: container) out << item << separator; out << finish; } template <class T> void remove_dup(vector<T> &a){ sort(ALL(a)); a.resize(unique(ALL(a)) - a.begin()); } #include "rail.h" void findLocation(int n, int first, int location[], int stype[]); namespace InteractorLib{ int getDistance(int i, int j){ cout << "? " << i << " " << j << endl; int ans; cin >> ans; return ans; } } // using namespace InteractorLib; void findLocation(int n, int first, int location[], int stype[]){ location[0] = first; stype[0] = 1; vector<int> dis0(n); for(int i = 1; i < n; ++i) dis0[i] = getDistance(0, i); vector<pair<int, int>> stations; for(int i = 1; i < n; ++i) stations.push_back(make_pair(dis0[i], i)); sort(ALL(stations)); int i1 = stations[0].second; location[i1] = location[0] + dis0[i1]; stype[i1] = 2; vector<int> dis1(n); for(int i = 1; i < n; ++i) if (i != i1){ dis1[i] = getDistance(i1, i); } vector<int> right_part, left_part; for(int i = 1; i < n-1; ++i){ int j = stations[i].second; if (dis0[i1] + dis1[j] == dis0[j]){ left_part.push_back(j); } else{ right_part.push_back(j); } } map<int, int> mp; // expand to the right int ma = -1; vector<int> S; for(int i: right_part){ if (ma == -1){ ma = i; stype[i] = 2; location[i] = dis0[i] + location[0]; S.push_back(location[i]); mp[location[i]] = i; continue; } int dih = getDistance(ma, i); if (dis0[ma] + dih == dis0[i]){ stype[i] = 1; location[i] = location[ma] - dih; } else{ int cur = *lower_bound(ALL(S), location[ma] - dih); cur = mp[cur]; if (getDistance(cur, i) == dih - (location[ma] - location[cur])){ stype[i] = 1; location[i] = location[ma] - dih; } else{ stype[i] = 2; location[i] = location[0] + dis0[i]; } } } // expand to the left S.clear(); int mi = -1; for(int i: left_part){ if (dis1[i] < dis0[i1]){ stype[i] = 1; location[i] = location[i1] - dis1[i]; continue; } if (mi == -1){ mi = i; stype[i] = 1; location[i] = location[i1] - dis1[i]; S.push_back(location[i]); mp[location[i]] = i; continue; } int dih = getDistance(mi, i); if (dis0[mi] + dih == dis0[i]){ stype[i] = 2; location[i] = location[mi] + dih; } else{ int cur = *lower_bound(ALL(S), location[mi] + dih, greater<int>()); cur = mp[cur]; if (getDistance(cur, i) == dih - (location[cur] - location[mi])){ stype[i] = 2; location[i] = location[mi] + dih; } else{ mi = i; stype[i] = 1; location[i] = location[i1] - dis1[i]; S.push_back(location[i]); mp[location[i]] = i; } } } } // int main(void){ // ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); // clock_t start = clock(); // int n; cin >> n; // int first; cin >> first; // int location[n], stype[n]; // findLocation(n, first, location, stype); // for(int i = 0; i < n; ++i) cout << location[i] << " " << stype[i] << "\n"; // cerr << "Time elapsed: " << clock() - start << "ms!\n"; // return 0; // }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...