Submission #1219461

#TimeUsernameProblemLanguageResultExecution timeMemory
1219461omsincoconutPortal (BOI24_portal)C++17
1 / 100
2093 ms2884 KiB
#include <bits/stdc++.h> using namespace std; const int MAXCOORD = 105; bool vis[2*MAXCOORD][2*MAXCOORD]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int N; cin >> N; if (N <= 2) { cout << -1; return 0; } int x[N+1], y[N+1]; for (int i = 1; i <= N; i++) cin >> x[i] >> y[i]; for (int i = 1; i <= N; i++) x[i] += MAXCOORD, y[i] += MAXCOORD; int ans = 0; for (int i = 0; i < 2*MAXCOORD; i++) { for (int j = 0; j < 2*MAXCOORD; j++) { if (vis[i][j]) continue; ans++; queue<pair<int, int>> bfs; bfs.emplace(i, j); while (!bfs.empty()) { auto [a, b] = bfs.front(); bfs.pop(); if (vis[a][b]) continue; vis[a][b] = true; for (int i = 2; i <= N; i++) { int na = a + x[i]-x[1], nb = b + y[i]-y[1]; if (0 <= na && na < 2*MAXCOORD && 0 <= nb && nb < 2*MAXCOORD) { bfs.emplace(na, nb); } } for (int i = 2; i <= N; i++) { int na = a + x[1]-x[i], nb = b + y[1]-y[i]; if (0 <= na && na < 2*MAXCOORD && 0 <= nb && nb < 2*MAXCOORD) { bfs.emplace(na, nb); } } } } } cout << ans; return 0; } /* 3 1 1 1 3 3 2 5 0 0 1 0 -1 0 0 1 0 -1 1 1 -1 */
#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...