Submission #994651

#TimeUsernameProblemLanguageResultExecution timeMemory
994651pavementPortal (BOI24_portal)C++17
11 / 100
67 ms12876 KiB
#include <bits/stdc++.h> using namespace std; #define pb push_back int N, horiz, vert, x[100005], y[100005]; map<int, vector<int> > row, col; int main() { ios::sync_with_stdio(0); cin.tie(0); cin >> N; for (int i = 1; i <= N; i++) { cin >> x[i] >> y[i]; row[x[i]].pb(y[i]); col[y[i]].pb(x[i]); } for (auto i : row) { sort(i.second.begin(), i.second.end()); if (i.second.size() > 1) { for (int j = 0; j + 1 < (int)i.second.size(); j++) { horiz = __gcd(horiz, i.second[j + 1] - i.second[j]); } } } for (auto i : col) { sort(i.second.begin(), i.second.end()); if (i.second.size() > 1) { for (int j = 0; j + 1 < (int)i.second.size(); j++) { vert = __gcd(vert, i.second[j + 1] - i.second[j]); } } } if (horiz == 0 || vert == 0) { cout << "-1\n"; } else { cout << (long long)horiz * vert << '\n'; } }
#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...