제출 #994707

#제출 시각아이디문제언어결과실행 시간메모리
994707hmm789Portal (BOI24_portal)C++14
0 / 100
2100 ms3188 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define MOD 1000000007 int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, ans = 0; cin >> n; int x[n], y[n]; for(int i = 0; i < n; i++) cin >> x[i] >> y[i]; if(n == 1) { cout << -1; return 0; } int grid[401][401]; memset(grid, -1, sizeof(grid)); for(int i = 0; i < 401; i++) { for(int j = 0; j < 401; j++) { if(grid[i][j] != -1) continue; queue<pair<int, int>> q; q.push({i,j}); grid[i][j] = ans; while(!q.empty()) { pair<int, int> c = q.front(); q.pop(); for(int r = 0; r < n; r++) { for(int s = 0; s < n; s++) { int nx = c.first+x[r]-x[s]; int ny = c.second+y[r]-y[s]; if(nx < 0 || nx > 400 || ny < 0 || ny > 400) continue; if(grid[nx][ny] != -1) continue; grid[nx][ny] = ans; q.push({nx, ny}); } } } ans++; } } cout << ans; }
#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...