Submission #994759

# Submission time Handle Problem Language Result Execution time Memory
994759 2024-06-08T04:58:46 Z hmm789 Portal (BOI24_portal) C++14
1 / 100
2000 ms 1372 KB
#include <bits/stdc++.h>
using namespace std;
#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];
	int X = 301, Y = 301;
	int grid[X][Y];
	memset(grid, -1, sizeof(grid));
	bool inf = false;
	for(int i = 0; i < X; i++) {
		for(int j = 0; j < Y; 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 >= X || ny < 0 || ny >= Y) continue;
						if(grid[nx][ny] != -1) continue;
						grid[nx][ny] = ans;
						q.push({nx, ny});
					}
				}
			}
			ans++;
			if(i == X-1 && j == Y-1) inf = true;
		}
	}
	if(inf) cout << -1;
	else cout << ans;
}

# Verdict Execution time Memory Grader output
1 Correct 3 ms 604 KB Output is correct
2 Correct 3 ms 604 KB Output is correct
3 Correct 3 ms 604 KB Output is correct
4 Correct 3 ms 604 KB Output is correct
5 Correct 3 ms 604 KB Output is correct
6 Correct 3 ms 604 KB Output is correct
7 Correct 4 ms 604 KB Output is correct
8 Correct 3 ms 604 KB Output is correct
9 Correct 3 ms 604 KB Output is correct
10 Correct 3 ms 604 KB Output is correct
11 Correct 3 ms 604 KB Output is correct
12 Correct 3 ms 604 KB Output is correct
13 Correct 3 ms 604 KB Output is correct
14 Correct 3 ms 604 KB Output is correct
15 Correct 4 ms 800 KB Output is correct
16 Correct 4 ms 604 KB Output is correct
17 Correct 3 ms 604 KB Output is correct
18 Correct 3 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 604 KB Output is correct
2 Correct 3 ms 604 KB Output is correct
3 Correct 3 ms 604 KB Output is correct
4 Correct 3 ms 604 KB Output is correct
5 Correct 3 ms 604 KB Output is correct
6 Correct 3 ms 604 KB Output is correct
7 Correct 4 ms 604 KB Output is correct
8 Correct 3 ms 604 KB Output is correct
9 Correct 3 ms 604 KB Output is correct
10 Correct 3 ms 604 KB Output is correct
11 Correct 3 ms 604 KB Output is correct
12 Correct 3 ms 604 KB Output is correct
13 Correct 3 ms 604 KB Output is correct
14 Correct 3 ms 604 KB Output is correct
15 Correct 4 ms 800 KB Output is correct
16 Correct 4 ms 604 KB Output is correct
17 Correct 3 ms 604 KB Output is correct
18 Correct 3 ms 604 KB Output is correct
19 Correct 3 ms 604 KB Output is correct
20 Incorrect 4 ms 804 KB Output isn't correct
21 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 604 KB Output is correct
2 Execution timed out 2093 ms 1372 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 604 KB Output is correct
2 Correct 4 ms 604 KB Output is correct
3 Correct 3 ms 604 KB Output is correct
4 Correct 1276 ms 816 KB Output is correct
5 Correct 1310 ms 600 KB Output is correct
6 Correct 1340 ms 600 KB Output is correct
7 Correct 1308 ms 788 KB Output is correct
8 Correct 1287 ms 600 KB Output is correct
9 Incorrect 11 ms 600 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 604 KB Output is correct
2 Correct 3 ms 604 KB Output is correct
3 Correct 3 ms 604 KB Output is correct
4 Correct 3 ms 604 KB Output is correct
5 Correct 3 ms 604 KB Output is correct
6 Correct 3 ms 604 KB Output is correct
7 Correct 4 ms 604 KB Output is correct
8 Correct 3 ms 604 KB Output is correct
9 Correct 3 ms 604 KB Output is correct
10 Correct 3 ms 604 KB Output is correct
11 Correct 3 ms 604 KB Output is correct
12 Correct 3 ms 604 KB Output is correct
13 Correct 3 ms 604 KB Output is correct
14 Correct 3 ms 604 KB Output is correct
15 Correct 4 ms 800 KB Output is correct
16 Correct 4 ms 604 KB Output is correct
17 Correct 3 ms 604 KB Output is correct
18 Correct 3 ms 604 KB Output is correct
19 Correct 3 ms 604 KB Output is correct
20 Incorrect 4 ms 804 KB Output isn't correct
21 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 604 KB Output is correct
2 Correct 3 ms 604 KB Output is correct
3 Correct 3 ms 604 KB Output is correct
4 Correct 3 ms 604 KB Output is correct
5 Correct 3 ms 604 KB Output is correct
6 Correct 3 ms 604 KB Output is correct
7 Correct 4 ms 604 KB Output is correct
8 Correct 3 ms 604 KB Output is correct
9 Correct 3 ms 604 KB Output is correct
10 Correct 3 ms 604 KB Output is correct
11 Correct 3 ms 604 KB Output is correct
12 Correct 3 ms 604 KB Output is correct
13 Correct 3 ms 604 KB Output is correct
14 Correct 3 ms 604 KB Output is correct
15 Correct 4 ms 800 KB Output is correct
16 Correct 4 ms 604 KB Output is correct
17 Correct 3 ms 604 KB Output is correct
18 Correct 3 ms 604 KB Output is correct
19 Correct 3 ms 604 KB Output is correct
20 Incorrect 4 ms 804 KB Output isn't correct
21 Halted 0 ms 0 KB -