# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
835718 |
2023-08-23T18:00:39 Z |
Mohmad_Zaid |
Keys (IOI21_keys) |
C++17 |
|
3000 ms |
1687604 KB |
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
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<int> final(n, 1);
vector<vector<pair<int,int>>>g(n,vector<pair<int,int>>());
vector<int>sizes(n,0);
vector<bool>vis(n);
vector<bool>vis2(n);
vector<vector<int>>need(n,vector<int>());
set<int>keys;
for(int i=0;i<m;i++){
g[u[i]].pb({v[i],c[i]});
g[v[i]].pb({u[i],c[i]});
}
int mn=INT_MAX;
for(int i=0;i<n;i++){
vis.assign(n,0);
vis2.assign(n,0);
need.assign(n,vector<int>());
queue<int>q;
q.push(i);
while(!q.empty()){
int par=q.front();
q.pop();
vis[par]=1;
if(!vis2[r[par]]){
for(auto node:need[r[par]]){
if(vis[node])continue;
q.push(node);
}
}
vis2[r[par]]=1;
for(auto node:g[par]){
if(vis[node.first])continue;
if(!vis2[node.second]){need[node.second].pb(node.first);continue;}
q.push(node.first);
}
}
for(int j=0;j<n;j++)sizes[i]+=vis[j];
mn=min(mn,sizes[i]);
}
for(int i=0;i<n;i++){
// cout<<"room: "<<i<<' '<<sizes[i]<<endl;
if(sizes[i]==mn)final[i]=1;
else final[i]=0;
}
return final;
}
// int main(){
// vector<int>test;
// vector<int>r={0, 1, 1, 2, 2, 1, 2},u={0, 0, 1, 1, 2, 3, 3, 4, 4, 5},
// v={1, 2, 2, 3, 3, 4, 5, 5, 6, 6},c={0, 0, 1, 0, 0, 1, 2, 0, 2, 1};
// test=find_reachable(r,u,v,c);
// for(int i=0;i<test.size();i++)cout<<test[i]<<' ';cout<<endl;
// return 0;
// }
# |
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 |
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 |
2 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 |
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 |
2 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 |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
0 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 |
1 ms |
336 KB |
Output is correct |
20 |
Correct |
0 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 |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 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 |
2 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 |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
0 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 |
1 ms |
336 KB |
Output is correct |
20 |
Correct |
0 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 |
33 ms |
624 KB |
Output is correct |
28 |
Correct |
33 ms |
624 KB |
Output is correct |
29 |
Correct |
34 ms |
596 KB |
Output is correct |
30 |
Correct |
21 ms |
340 KB |
Output is correct |
31 |
Correct |
6 ms |
340 KB |
Output is correct |
32 |
Correct |
1 ms |
340 KB |
Output is correct |
33 |
Correct |
3 ms |
340 KB |
Output is correct |
34 |
Correct |
14 ms |
340 KB |
Output is correct |
35 |
Correct |
25 ms |
340 KB |
Output is correct |
36 |
Correct |
96 ms |
592 KB |
Output is correct |
37 |
Correct |
58 ms |
468 KB |
Output is correct |
38 |
Correct |
81 ms |
588 KB |
Output is correct |
39 |
Correct |
73 ms |
760 KB |
Output is correct |
40 |
Correct |
12 ms |
340 KB |
Output is correct |
41 |
Correct |
85 ms |
500 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 |
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 |
2 ms |
212 KB |
Output is correct |
10 |
Execution timed out |
3117 ms |
1687604 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 |
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 |
2 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 |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
0 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 |
1 ms |
336 KB |
Output is correct |
20 |
Correct |
0 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 |
33 ms |
624 KB |
Output is correct |
28 |
Correct |
33 ms |
624 KB |
Output is correct |
29 |
Correct |
34 ms |
596 KB |
Output is correct |
30 |
Correct |
21 ms |
340 KB |
Output is correct |
31 |
Correct |
6 ms |
340 KB |
Output is correct |
32 |
Correct |
1 ms |
340 KB |
Output is correct |
33 |
Correct |
3 ms |
340 KB |
Output is correct |
34 |
Correct |
14 ms |
340 KB |
Output is correct |
35 |
Correct |
25 ms |
340 KB |
Output is correct |
36 |
Correct |
96 ms |
592 KB |
Output is correct |
37 |
Correct |
58 ms |
468 KB |
Output is correct |
38 |
Correct |
81 ms |
588 KB |
Output is correct |
39 |
Correct |
73 ms |
760 KB |
Output is correct |
40 |
Correct |
12 ms |
340 KB |
Output is correct |
41 |
Correct |
85 ms |
500 KB |
Output is correct |
42 |
Execution timed out |
3117 ms |
1687604 KB |
Time limit exceeded |
43 |
Halted |
0 ms |
0 KB |
- |