Submission #835497

# Submission time Handle Problem Language Result Execution time Memory
835497 2023-08-23T15:12:27 Z IS_Rushdi Keys (IOI21_keys) C++17
37 / 100
3000 ms 23832 KB
#include <bits/stdc++.h>
using namespace std;
 
 
 
vector<int> find_reachable(vector<int> r, vector<int> u, vector<int> v, vector<int> c) {
	vector<int> ans(r.size(), 1);
    int n = r.size();
    int m = u.size();
    vector<vector<pair<int,int>>>a(n);
    for(int i = 0; i < m; i++){
        a[v[i]].push_back({u[i],c[i]});
        a[u[i]].push_back({v[i],c[i]});
    }
    int mn = 2e9;
    vector<int>cnt(n);
    for(int i = 0; i < n; i++){
        vector<bool>vis(n);
        vector<bool>vis2(n);
        vector<vector<int>>arr(n,vector<int>());
        queue<int>q;
        q.push(i);
        while(!q.empty()){
            int node = q.front();
            q.pop();
            if(vis[node]) continue;
            vis[node]=1;
            if(!vis2[r[node]]){
                vis2[r[node]]=1;
                for(int to : arr[r[node]]){
                    if(vis[to]) continue;
                    q.push(to);
                }
            }
            for(pair<int,int> to : a[node]){
                if(vis[to.first]) continue;
                if(!vis2[to.second]){
                    arr[to.second].push_back(to.first);
                }else{
                    q.push(to.first);
                }
            }
        }
        for(int j = 0; j < n; j++){
            if(vis[j]) cnt[i]++;
        }
        mn = min(mn,cnt[i]);
    }
    for(int i = 0; i < n; i++){
        if(cnt[i] == mn) ans[i] = 1;
        else ans[i] = 0;
    }
    return ans;
}
// int main(){
//     int n; cin >> n;
//     vector<int>a(n);
//     for(int i = 0; i < n; i++) cin >> a[i];
//     int m; cin >> m;
//     vector<int>b(m),c(m),d(m);
//     for(int i = 0; i < m; i++) cin >> b[i];
//     for(int i = 0; i < m; i++) cin >> c[i];
//     for(int i = 0; i < m; i++) cin >> d[i];
//     vector<int>ans =  find_reachable(a,b,c,d);
//     for(int i = 0; i < n; i++) cout << ans[i] << ' ';
    
// }
# 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 0 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 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 0 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 212 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 0 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 2 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 212 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 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 0 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 212 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 0 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 2 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 212 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 63 ms 560 KB Output is correct
28 Correct 62 ms 468 KB Output is correct
29 Correct 66 ms 560 KB Output is correct
30 Correct 42 ms 340 KB Output is correct
31 Correct 5 ms 428 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Correct 3 ms 340 KB Output is correct
34 Correct 13 ms 412 KB Output is correct
35 Correct 21 ms 340 KB Output is correct
36 Correct 89 ms 468 KB Output is correct
37 Correct 59 ms 468 KB Output is correct
38 Correct 84 ms 468 KB Output is correct
39 Correct 68 ms 468 KB Output is correct
40 Correct 9 ms 340 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 0 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 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Execution timed out 3031 ms 23832 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 0 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 212 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 0 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 2 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 212 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 63 ms 560 KB Output is correct
28 Correct 62 ms 468 KB Output is correct
29 Correct 66 ms 560 KB Output is correct
30 Correct 42 ms 340 KB Output is correct
31 Correct 5 ms 428 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Correct 3 ms 340 KB Output is correct
34 Correct 13 ms 412 KB Output is correct
35 Correct 21 ms 340 KB Output is correct
36 Correct 89 ms 468 KB Output is correct
37 Correct 59 ms 468 KB Output is correct
38 Correct 84 ms 468 KB Output is correct
39 Correct 68 ms 468 KB Output is correct
40 Correct 9 ms 340 KB Output is correct
41 Correct 44 ms 468 KB Output is correct
42 Execution timed out 3031 ms 23832 KB Time limit exceeded
43 Halted 0 ms 0 KB -