# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
528060 | 2022-02-19T05:35:25 Z | qwerasdfzxcl | From Hacks to Snitches (BOI21_watchmen) | C++14 | 1039 ms | 55932 KB |
#include <bits/stdc++.h> typedef long long ll; using namespace std; const int INF = 1e9; int dist[100100][125], a[125]; vector<int> adj[100100]; int main(){ int n, m; scanf("%d %d", &n, &m); for (int i=1;i<=n;i++) adj[i].push_back(i); for (int i=0;i<m;i++){ int x, y; scanf("%d %d", &x, &y); adj[x].push_back(y); adj[y].push_back(x); } int k, x; scanf("%d", &k); for (int i=0;i<k;i++){ scanf("%d", &x); for (int j=0;j<x;j++) scanf("%d", a+j); } for (int i=1;i<=n;i++) fill(dist[i], dist[i]+125, INF); dist[1][0] = 0; queue<pair<int, int>> q; q.emplace(1, 0); while(!q.empty()){ auto p = q.front(); q.pop(); //printf("%d %d: %d\n", p.first, p.second, dist[p.first][p.second]); int ct = p.second, nt = p.second + 1; if (nt>=x) nt = 0; for (auto &v:adj[p.first]){ if (a[nt]==v) continue; if (a[ct]==v && a[nt]==p.first) continue; if (dist[v][nt] <= dist[p.first][p.second] + 1) continue; dist[v][nt] = dist[p.first][p.second] + 1; q.emplace(v, nt); } } int ans = *min_element(dist[n], dist[n]+125); if (ans==INF) printf("impossible\n"); else printf("%d\n", ans); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 50 ms | 4344 KB | Output is correct |
2 | Correct | 435 ms | 55836 KB | Output is correct |
3 | Correct | 670 ms | 51104 KB | Output is correct |
4 | Correct | 1024 ms | 51188 KB | Output is correct |
5 | Correct | 3 ms | 2636 KB | Output is correct |
6 | Correct | 754 ms | 51136 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 54 ms | 4348 KB | Output is correct |
2 | Correct | 449 ms | 55932 KB | Output is correct |
3 | Correct | 680 ms | 51108 KB | Output is correct |
4 | Correct | 1039 ms | 51188 KB | Output is correct |
5 | Correct | 2 ms | 2648 KB | Output is correct |
6 | Correct | 832 ms | 51192 KB | Output is correct |
7 | Incorrect | 264 ms | 51184 KB | Output isn't correct |
8 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 54 ms | 4348 KB | Output is correct |
2 | Correct | 449 ms | 55932 KB | Output is correct |
3 | Correct | 680 ms | 51108 KB | Output is correct |
4 | Correct | 1039 ms | 51188 KB | Output is correct |
5 | Correct | 2 ms | 2648 KB | Output is correct |
6 | Correct | 832 ms | 51192 KB | Output is correct |
7 | Incorrect | 264 ms | 51184 KB | Output isn't correct |
8 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 54 ms | 4348 KB | Output is correct |
2 | Correct | 449 ms | 55932 KB | Output is correct |
3 | Correct | 680 ms | 51108 KB | Output is correct |
4 | Correct | 1039 ms | 51188 KB | Output is correct |
5 | Correct | 2 ms | 2648 KB | Output is correct |
6 | Correct | 832 ms | 51192 KB | Output is correct |
7 | Incorrect | 264 ms | 51184 KB | Output isn't correct |
8 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 50 ms | 4344 KB | Output is correct |
2 | Correct | 435 ms | 55836 KB | Output is correct |
3 | Correct | 670 ms | 51104 KB | Output is correct |
4 | Correct | 1024 ms | 51188 KB | Output is correct |
5 | Correct | 3 ms | 2636 KB | Output is correct |
6 | Correct | 754 ms | 51136 KB | Output is correct |
7 | Correct | 54 ms | 4348 KB | Output is correct |
8 | Correct | 449 ms | 55932 KB | Output is correct |
9 | Correct | 680 ms | 51108 KB | Output is correct |
10 | Correct | 1039 ms | 51188 KB | Output is correct |
11 | Correct | 2 ms | 2648 KB | Output is correct |
12 | Correct | 832 ms | 51192 KB | Output is correct |
13 | Incorrect | 264 ms | 51184 KB | Output isn't correct |
14 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 50 ms | 4344 KB | Output is correct |
2 | Correct | 435 ms | 55836 KB | Output is correct |
3 | Correct | 670 ms | 51104 KB | Output is correct |
4 | Correct | 1024 ms | 51188 KB | Output is correct |
5 | Correct | 3 ms | 2636 KB | Output is correct |
6 | Correct | 754 ms | 51136 KB | Output is correct |
7 | Correct | 54 ms | 4348 KB | Output is correct |
8 | Correct | 449 ms | 55932 KB | Output is correct |
9 | Correct | 680 ms | 51108 KB | Output is correct |
10 | Correct | 1039 ms | 51188 KB | Output is correct |
11 | Correct | 2 ms | 2648 KB | Output is correct |
12 | Correct | 832 ms | 51192 KB | Output is correct |
13 | Incorrect | 264 ms | 51184 KB | Output isn't correct |
14 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 50 ms | 4344 KB | Output is correct |
2 | Correct | 435 ms | 55836 KB | Output is correct |
3 | Correct | 670 ms | 51104 KB | Output is correct |
4 | Correct | 1024 ms | 51188 KB | Output is correct |
5 | Correct | 3 ms | 2636 KB | Output is correct |
6 | Correct | 754 ms | 51136 KB | Output is correct |
7 | Correct | 54 ms | 4348 KB | Output is correct |
8 | Correct | 449 ms | 55932 KB | Output is correct |
9 | Correct | 680 ms | 51108 KB | Output is correct |
10 | Correct | 1039 ms | 51188 KB | Output is correct |
11 | Correct | 2 ms | 2648 KB | Output is correct |
12 | Correct | 832 ms | 51192 KB | Output is correct |
13 | Incorrect | 264 ms | 51184 KB | Output isn't correct |
14 | Halted | 0 ms | 0 KB | - |