Submission #1076551

#TimeUsernameProblemLanguageResultExecution timeMemory
1076551raphaelpPortal (BOI24_portal)C++14
11 / 100
2048 ms60444 KiB
#include <bits/stdc++.h> using namespace std; int main() { long long N; cin >> N; long long X, Y; cin >> X >> Y; vector<pair<long long, long long>> Tab; for (long long i = 0; i < N - 1; i++) { long long x, y; cin >> x >> y; Tab.push_back({x - X, y - Y}); } if (N <= 2) { cout << -1; return 0; } vector<pair<long long, long long>> Tab2; random_shuffle(Tab.begin(), Tab.end()); while (!Tab.empty() && Tab[0].first == 0) { Tab2.push_back(Tab[0]); swap(Tab[0], Tab[Tab.size() - 1]); Tab.pop_back(); } while (Tab.size() > 1) { while (Tab.size() > 1 && Tab[1].first == 0) { swap(Tab[1], Tab[Tab.size() - 1]); Tab2.push_back(Tab[Tab.size() - 1]); Tab.pop_back(); } if (Tab.size() == 1) break; if (abs(Tab[1].first) < abs(Tab[0].first)) swap(Tab[1], Tab[0]); long long x = Tab[1].first / Tab[0].first; Tab[1].first -= Tab[0].first * x; Tab[1].second -= Tab[0].second * x; if (Tab[1].first == 0 && Tab[1].second != 0) { x = Tab[0].second / Tab[1].second; Tab[0].second -= Tab[1].second * x; } while (Tab[0].second > 1000000000000) cout << 1; } while (!Tab2.empty() && Tab2[0].second == 0) { swap(Tab2[0], Tab2[Tab2.size() - 1]); Tab2.pop_back(); } while (Tab2.size() > 1) { while (Tab2.size() > 1 && Tab2[1].second == 0) { swap(Tab2[1], Tab2[Tab2.size() - 1]); Tab2.pop_back(); } if (Tab2.size() == 1) break; if (abs(Tab2[1].second) < abs(Tab2[0].second)) swap(Tab2[1], Tab2[0]); long long x = Tab2[1].second / Tab2[0].second; Tab2[1].second -= Tab2[0].second * x; } if (Tab2.empty()) cout << -1; else cout << abs(Tab[0].first * Tab2[0].second); }
#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...