Submission #796177

# Submission time Handle Problem Language Result Execution time Memory
796177 2023-07-28T07:26:38 Z t6twotwo Keys (IOI21_keys) C++17
37 / 100
3000 ms 24476 KB
#include "keys.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
vector<int> find_reachable(vector<int> R, vector<int> U, vector<int> V, vector<int> C) {
    int N = R.size(), M = C.size();
    vector<vector<pair<int, int>>> adj(N);
    for (int i = 0; i < M; i++) {
        adj[U[i]].emplace_back(V[i], C[i]);
        adj[V[i]].emplace_back(U[i], C[i]);
    }
    vector<int> p(N);
    for (int i = 0; i < N; i++) {
        vector<bool> have(N), vis(N);
        vector<vector<int>> w(N);
        queue<int> q;
        vis[i] = 1;
        q.push(i);
        while (!q.empty()) {
            int x = q.front();
            q.pop();
            p[i]++;
            have[R[x]] = 1;
            for (int y : w[R[x]]) {
                if (!vis[y]) {
                    vis[y] = 1;
                    q.push(y);
                }
            }
            w[R[x]].clear();
            for (auto [y, z] : adj[x]) {
                if (vis[y]) {
                    continue;
                }
                if (have[z]) {
                    vis[y] = 1;
                    q.push(y);
                } else {
                    w[z].push_back(y);
                }
            }
        }
    }
    int mn = *min_element(p.begin(), p.end());
    vector<int> ans(N);
    for (int i = 0; i < N; i++) {
        if (p[i] == mn) {
            ans[i] = 1;
        }
    }
    return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 300 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 300 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 300 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 300 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 296 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 2 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 0 ms 296 KB Output is correct
20 Correct 0 ms 296 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 300 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 300 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 296 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 2 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 0 ms 296 KB Output is correct
20 Correct 0 ms 296 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 50 ms 584 KB Output is correct
28 Correct 49 ms 596 KB Output is correct
29 Correct 49 ms 584 KB Output is correct
30 Correct 40 ms 340 KB Output is correct
31 Correct 3 ms 340 KB Output is correct
32 Correct 1 ms 308 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 11 ms 424 KB Output is correct
35 Correct 18 ms 416 KB Output is correct
36 Correct 75 ms 516 KB Output is correct
37 Correct 53 ms 512 KB Output is correct
38 Correct 77 ms 436 KB Output is correct
39 Correct 63 ms 532 KB Output is correct
40 Correct 6 ms 340 KB Output is correct
41 Correct 27 ms 508 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 300 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 300 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Execution timed out 3012 ms 24476 KB Time limit exceeded
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 300 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 300 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 296 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 2 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 0 ms 296 KB Output is correct
20 Correct 0 ms 296 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 50 ms 584 KB Output is correct
28 Correct 49 ms 596 KB Output is correct
29 Correct 49 ms 584 KB Output is correct
30 Correct 40 ms 340 KB Output is correct
31 Correct 3 ms 340 KB Output is correct
32 Correct 1 ms 308 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 11 ms 424 KB Output is correct
35 Correct 18 ms 416 KB Output is correct
36 Correct 75 ms 516 KB Output is correct
37 Correct 53 ms 512 KB Output is correct
38 Correct 77 ms 436 KB Output is correct
39 Correct 63 ms 532 KB Output is correct
40 Correct 6 ms 340 KB Output is correct
41 Correct 27 ms 508 KB Output is correct
42 Execution timed out 3012 ms 24476 KB Time limit exceeded
43 Halted 0 ms 0 KB -