Submission #599192

# Submission time Handle Problem Language Result Execution time Memory
599192 2022-07-19T11:29:25 Z lcj Keys (IOI21_keys) C++17
37 / 100
3000 ms 28564 KB
#include <bits/stdc++.h>
#include "keys.h"
#define all(x) x.begin(), x.end()

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

vector<int> find_reachable(vector<int> r, vector<int> u, vector<int> v, vector<int> c) {
	int n = r.size();int m = u.size();
    vector<vector<pii>> adj(n);
    for (int i = 0; i < m; i++)
    {
        adj[u[i]].push_back({v[i], c[i]});
        adj[v[i]].push_back({u[i], c[i]});
    }
    vector<int> reach(n, 0);
    for (int i = 0; i < n; i++)
    {
        vector<bool> mkeys(n, 0);
        vector<bool> vis(n, 0);
        int vcount = 0;
        vector<vector<int>> unlockables(n);
        queue<int> q;
        q.push(i);
        while (!q.empty())
        {
            int cn = q.front();q.pop();
            if (vis[cn]) continue;
            vis[cn] = 1;
            vcount++;
            mkeys[r[cn]] = 1;
            for (int j : unlockables[r[cn]]) {
                q.push(j);
            }
            unlockables[r[cn]].clear();
            for (auto nn : adj[cn]) {
                if (mkeys[nn.second]) {
                    q.push(nn.first);
                }
                else {
                    unlockables[nn.second].push_back(nn.first);
                }
            }
        }
        reach[i] = vcount;
    }
    int mr = *min_element(all(reach));    
    vector<int> ans(n);
    for (int i = 0; i < n; i++)
    {
        ans[i] = reach[i] == mr;
    }
	return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 304 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 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 304 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 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 2 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 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 3 ms 212 KB Output is correct
16 Correct 1 ms 300 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 2 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 2 ms 296 KB Output is correct
24 Correct 2 ms 296 KB Output is correct
25 Correct 2 ms 212 KB Output is correct
26 Correct 2 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 304 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 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 2 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 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 3 ms 212 KB Output is correct
16 Correct 1 ms 300 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 2 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 2 ms 296 KB Output is correct
24 Correct 2 ms 296 KB Output is correct
25 Correct 2 ms 212 KB Output is correct
26 Correct 2 ms 212 KB Output is correct
27 Correct 82 ms 596 KB Output is correct
28 Correct 75 ms 596 KB Output is correct
29 Correct 75 ms 588 KB Output is correct
30 Correct 74 ms 408 KB Output is correct
31 Correct 3 ms 340 KB Output is correct
32 Correct 2 ms 348 KB Output is correct
33 Correct 4 ms 336 KB Output is correct
34 Correct 25 ms 340 KB Output is correct
35 Correct 33 ms 340 KB Output is correct
36 Correct 129 ms 468 KB Output is correct
37 Correct 93 ms 468 KB Output is correct
38 Correct 138 ms 536 KB Output is correct
39 Correct 125 ms 544 KB Output is correct
40 Correct 8 ms 468 KB Output is correct
41 Correct 44 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 304 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 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Execution timed out 3054 ms 28564 KB Time limit exceeded
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 304 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 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 2 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 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 3 ms 212 KB Output is correct
16 Correct 1 ms 300 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 2 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 2 ms 296 KB Output is correct
24 Correct 2 ms 296 KB Output is correct
25 Correct 2 ms 212 KB Output is correct
26 Correct 2 ms 212 KB Output is correct
27 Correct 82 ms 596 KB Output is correct
28 Correct 75 ms 596 KB Output is correct
29 Correct 75 ms 588 KB Output is correct
30 Correct 74 ms 408 KB Output is correct
31 Correct 3 ms 340 KB Output is correct
32 Correct 2 ms 348 KB Output is correct
33 Correct 4 ms 336 KB Output is correct
34 Correct 25 ms 340 KB Output is correct
35 Correct 33 ms 340 KB Output is correct
36 Correct 129 ms 468 KB Output is correct
37 Correct 93 ms 468 KB Output is correct
38 Correct 138 ms 536 KB Output is correct
39 Correct 125 ms 544 KB Output is correct
40 Correct 8 ms 468 KB Output is correct
41 Correct 44 ms 468 KB Output is correct
42 Execution timed out 3054 ms 28564 KB Time limit exceeded
43 Halted 0 ms 0 KB -