# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1040434 |
2024-08-01T03:59:30 Z |
vjudge1 |
Toy Train (IOI17_train) |
C++17 |
|
1082 ms |
4188 KB |
#include "train.h"
#include<bits/stdc++.h>
using namespace std;
set<int>radj[5010],adj[5010];
set<int>inv(vector<int>v,set<int>st){
for(auto i:v)
st.erase(i);
return st;
}
vector<int>aset(set<int>v,vector<int>own){
vector<int>cnt(5000),don(5000);
queue<int>q;
vector<int>ans;
for(auto i:v)
q.push(i),don[i]=1;
while(q.size()){
int x=q.front(); q.pop();
ans.push_back(x);
for(auto i:radj[x]) {
if(don[i])continue;
if(own[i]) q.push(i),don[i]=1;
else if(++cnt[i]==adj[i].size())
q.push(i),don[i]=1;
}
}
return ans;
}
std::vector<int> who_wins(std::vector<int> a, std::vector<int> r, std::vector<int> u, std::vector<int> v) {
int N=a.size(),M=u.size();
std::vector<int> res(a.size()),bozo=a;
for(auto&i:bozo)i=!i;
for(int i=0;i<M;i++)
adj[u[i]].insert(v[i]),
radj[v[i]].insert(u[i]);
set<int>charg,hav;
for(int i=0;i<N;hav.insert(i++))
if(r[i])charg.insert(i);
int CC=N;
while(CC) {
vector<int>v=aset(charg,a);
if(v.size()==CC){
for(auto i:v)
res[i]=1;
break;
}
v=aset(inv(v,hav),bozo);
for(auto i:v){ CC--;
charg.erase(i);
hav.erase(i);
for(auto j:adj[i])
radj[j].erase(i);
for(auto j:radj[i])
adj[j].erase(i);
adj[i].clear();
radj[i].clear();
}
}
return res;
}
Compilation message
train.cpp: In function 'std::vector<int> aset(std::set<int>, std::vector<int>)':
train.cpp:22:29: warning: comparison of integer expressions of different signedness: '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} and 'std::set<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
22 | else if(++cnt[i]==adj[i].size())
| ~~~~~~~~^~~~~~~~~~~~~~~
train.cpp: In function 'std::vector<int> who_wins(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
train.cpp:41:20: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
41 | if(v.size()==CC){
| ~~~~~~~~^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
2396 KB |
Output is correct |
2 |
Correct |
7 ms |
2560 KB |
Output is correct |
3 |
Correct |
6 ms |
2532 KB |
Output is correct |
4 |
Correct |
7 ms |
2360 KB |
Output is correct |
5 |
Correct |
6 ms |
2532 KB |
Output is correct |
6 |
Correct |
5 ms |
2368 KB |
Output is correct |
7 |
Correct |
5 ms |
2396 KB |
Output is correct |
8 |
Correct |
7 ms |
2396 KB |
Output is correct |
9 |
Correct |
5 ms |
2356 KB |
Output is correct |
10 |
Correct |
7 ms |
2288 KB |
Output is correct |
11 |
Correct |
4 ms |
2140 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
860 KB |
Output is correct |
2 |
Correct |
0 ms |
860 KB |
Output is correct |
3 |
Correct |
0 ms |
860 KB |
Output is correct |
4 |
Correct |
0 ms |
860 KB |
Output is correct |
5 |
Correct |
1 ms |
860 KB |
Output is correct |
6 |
Correct |
0 ms |
860 KB |
Output is correct |
7 |
Correct |
1 ms |
860 KB |
Output is correct |
8 |
Correct |
0 ms |
860 KB |
Output is correct |
9 |
Correct |
0 ms |
860 KB |
Output is correct |
10 |
Correct |
0 ms |
860 KB |
Output is correct |
11 |
Correct |
1 ms |
860 KB |
Output is correct |
12 |
Correct |
0 ms |
860 KB |
Output is correct |
13 |
Correct |
0 ms |
860 KB |
Output is correct |
14 |
Correct |
0 ms |
860 KB |
Output is correct |
15 |
Correct |
0 ms |
860 KB |
Output is correct |
16 |
Correct |
0 ms |
860 KB |
Output is correct |
17 |
Correct |
0 ms |
860 KB |
Output is correct |
18 |
Correct |
0 ms |
860 KB |
Output is correct |
19 |
Correct |
0 ms |
860 KB |
Output is correct |
20 |
Correct |
0 ms |
860 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
361 ms |
3968 KB |
Output is correct |
2 |
Correct |
593 ms |
3932 KB |
Output is correct |
3 |
Correct |
723 ms |
4188 KB |
Output is correct |
4 |
Correct |
9 ms |
3928 KB |
Output is correct |
5 |
Correct |
11 ms |
3932 KB |
Output is correct |
6 |
Correct |
11 ms |
3872 KB |
Output is correct |
7 |
Correct |
8 ms |
3932 KB |
Output is correct |
8 |
Correct |
10 ms |
3932 KB |
Output is correct |
9 |
Correct |
10 ms |
3780 KB |
Output is correct |
10 |
Correct |
11 ms |
3676 KB |
Output is correct |
11 |
Correct |
11 ms |
3796 KB |
Output is correct |
12 |
Correct |
9 ms |
3676 KB |
Output is correct |
13 |
Correct |
8 ms |
3620 KB |
Output is correct |
14 |
Correct |
8 ms |
3676 KB |
Output is correct |
15 |
Correct |
8 ms |
3676 KB |
Output is correct |
16 |
Correct |
8 ms |
3676 KB |
Output is correct |
17 |
Correct |
7 ms |
3556 KB |
Output is correct |
18 |
Correct |
998 ms |
2880 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
3420 KB |
Output is correct |
2 |
Correct |
8 ms |
3596 KB |
Output is correct |
3 |
Correct |
10 ms |
3932 KB |
Output is correct |
4 |
Correct |
13 ms |
3960 KB |
Output is correct |
5 |
Correct |
11 ms |
3948 KB |
Output is correct |
6 |
Correct |
10 ms |
3672 KB |
Output is correct |
7 |
Correct |
11 ms |
3920 KB |
Output is correct |
8 |
Correct |
12 ms |
3676 KB |
Output is correct |
9 |
Correct |
10 ms |
3928 KB |
Output is correct |
10 |
Correct |
7 ms |
3988 KB |
Output is correct |
11 |
Correct |
8 ms |
4188 KB |
Output is correct |
12 |
Correct |
8 ms |
4088 KB |
Output is correct |
13 |
Correct |
10 ms |
3928 KB |
Output is correct |
14 |
Correct |
9 ms |
3576 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
3932 KB |
Output is correct |
2 |
Correct |
7 ms |
3676 KB |
Output is correct |
3 |
Correct |
9 ms |
3932 KB |
Output is correct |
4 |
Correct |
6 ms |
3420 KB |
Output is correct |
5 |
Correct |
1 ms |
1116 KB |
Output is correct |
6 |
Correct |
4 ms |
2396 KB |
Output is correct |
7 |
Correct |
8 ms |
2980 KB |
Output is correct |
8 |
Correct |
10 ms |
3092 KB |
Output is correct |
9 |
Correct |
9 ms |
3164 KB |
Output is correct |
10 |
Correct |
3 ms |
1368 KB |
Output is correct |
11 |
Correct |
8 ms |
2908 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
2396 KB |
Output is correct |
2 |
Correct |
7 ms |
2560 KB |
Output is correct |
3 |
Correct |
6 ms |
2532 KB |
Output is correct |
4 |
Correct |
7 ms |
2360 KB |
Output is correct |
5 |
Correct |
6 ms |
2532 KB |
Output is correct |
6 |
Correct |
5 ms |
2368 KB |
Output is correct |
7 |
Correct |
5 ms |
2396 KB |
Output is correct |
8 |
Correct |
7 ms |
2396 KB |
Output is correct |
9 |
Correct |
5 ms |
2356 KB |
Output is correct |
10 |
Correct |
7 ms |
2288 KB |
Output is correct |
11 |
Correct |
4 ms |
2140 KB |
Output is correct |
12 |
Correct |
1 ms |
860 KB |
Output is correct |
13 |
Correct |
0 ms |
860 KB |
Output is correct |
14 |
Correct |
0 ms |
860 KB |
Output is correct |
15 |
Correct |
0 ms |
860 KB |
Output is correct |
16 |
Correct |
1 ms |
860 KB |
Output is correct |
17 |
Correct |
0 ms |
860 KB |
Output is correct |
18 |
Correct |
1 ms |
860 KB |
Output is correct |
19 |
Correct |
0 ms |
860 KB |
Output is correct |
20 |
Correct |
0 ms |
860 KB |
Output is correct |
21 |
Correct |
0 ms |
860 KB |
Output is correct |
22 |
Correct |
1 ms |
860 KB |
Output is correct |
23 |
Correct |
0 ms |
860 KB |
Output is correct |
24 |
Correct |
0 ms |
860 KB |
Output is correct |
25 |
Correct |
0 ms |
860 KB |
Output is correct |
26 |
Correct |
0 ms |
860 KB |
Output is correct |
27 |
Correct |
0 ms |
860 KB |
Output is correct |
28 |
Correct |
0 ms |
860 KB |
Output is correct |
29 |
Correct |
0 ms |
860 KB |
Output is correct |
30 |
Correct |
0 ms |
860 KB |
Output is correct |
31 |
Correct |
0 ms |
860 KB |
Output is correct |
32 |
Correct |
361 ms |
3968 KB |
Output is correct |
33 |
Correct |
593 ms |
3932 KB |
Output is correct |
34 |
Correct |
723 ms |
4188 KB |
Output is correct |
35 |
Correct |
9 ms |
3928 KB |
Output is correct |
36 |
Correct |
11 ms |
3932 KB |
Output is correct |
37 |
Correct |
11 ms |
3872 KB |
Output is correct |
38 |
Correct |
8 ms |
3932 KB |
Output is correct |
39 |
Correct |
10 ms |
3932 KB |
Output is correct |
40 |
Correct |
10 ms |
3780 KB |
Output is correct |
41 |
Correct |
11 ms |
3676 KB |
Output is correct |
42 |
Correct |
11 ms |
3796 KB |
Output is correct |
43 |
Correct |
9 ms |
3676 KB |
Output is correct |
44 |
Correct |
8 ms |
3620 KB |
Output is correct |
45 |
Correct |
8 ms |
3676 KB |
Output is correct |
46 |
Correct |
8 ms |
3676 KB |
Output is correct |
47 |
Correct |
8 ms |
3676 KB |
Output is correct |
48 |
Correct |
7 ms |
3556 KB |
Output is correct |
49 |
Correct |
998 ms |
2880 KB |
Output is correct |
50 |
Correct |
7 ms |
3420 KB |
Output is correct |
51 |
Correct |
8 ms |
3596 KB |
Output is correct |
52 |
Correct |
10 ms |
3932 KB |
Output is correct |
53 |
Correct |
13 ms |
3960 KB |
Output is correct |
54 |
Correct |
11 ms |
3948 KB |
Output is correct |
55 |
Correct |
10 ms |
3672 KB |
Output is correct |
56 |
Correct |
11 ms |
3920 KB |
Output is correct |
57 |
Correct |
12 ms |
3676 KB |
Output is correct |
58 |
Correct |
10 ms |
3928 KB |
Output is correct |
59 |
Correct |
7 ms |
3988 KB |
Output is correct |
60 |
Correct |
8 ms |
4188 KB |
Output is correct |
61 |
Correct |
8 ms |
4088 KB |
Output is correct |
62 |
Correct |
10 ms |
3928 KB |
Output is correct |
63 |
Correct |
9 ms |
3576 KB |
Output is correct |
64 |
Correct |
10 ms |
3932 KB |
Output is correct |
65 |
Correct |
7 ms |
3676 KB |
Output is correct |
66 |
Correct |
9 ms |
3932 KB |
Output is correct |
67 |
Correct |
6 ms |
3420 KB |
Output is correct |
68 |
Correct |
1 ms |
1116 KB |
Output is correct |
69 |
Correct |
4 ms |
2396 KB |
Output is correct |
70 |
Correct |
8 ms |
2980 KB |
Output is correct |
71 |
Correct |
10 ms |
3092 KB |
Output is correct |
72 |
Correct |
9 ms |
3164 KB |
Output is correct |
73 |
Correct |
3 ms |
1368 KB |
Output is correct |
74 |
Correct |
8 ms |
2908 KB |
Output is correct |
75 |
Correct |
355 ms |
3948 KB |
Output is correct |
76 |
Correct |
653 ms |
4000 KB |
Output is correct |
77 |
Correct |
806 ms |
4012 KB |
Output is correct |
78 |
Correct |
788 ms |
3980 KB |
Output is correct |
79 |
Correct |
793 ms |
3928 KB |
Output is correct |
80 |
Correct |
10 ms |
3932 KB |
Output is correct |
81 |
Correct |
10 ms |
4036 KB |
Output is correct |
82 |
Correct |
11 ms |
3932 KB |
Output is correct |
83 |
Correct |
11 ms |
4000 KB |
Output is correct |
84 |
Correct |
13 ms |
3932 KB |
Output is correct |
85 |
Correct |
13 ms |
3808 KB |
Output is correct |
86 |
Correct |
13 ms |
4048 KB |
Output is correct |
87 |
Correct |
11 ms |
3932 KB |
Output is correct |
88 |
Correct |
15 ms |
3932 KB |
Output is correct |
89 |
Correct |
11 ms |
3932 KB |
Output is correct |
90 |
Correct |
23 ms |
3896 KB |
Output is correct |
91 |
Correct |
22 ms |
3944 KB |
Output is correct |
92 |
Correct |
43 ms |
3932 KB |
Output is correct |
93 |
Correct |
43 ms |
3932 KB |
Output is correct |
94 |
Correct |
40 ms |
3928 KB |
Output is correct |
95 |
Correct |
43 ms |
3928 KB |
Output is correct |
96 |
Correct |
188 ms |
3696 KB |
Output is correct |
97 |
Correct |
707 ms |
4032 KB |
Output is correct |
98 |
Correct |
1018 ms |
3952 KB |
Output is correct |
99 |
Correct |
1082 ms |
3928 KB |
Output is correct |
100 |
Correct |
989 ms |
2648 KB |
Output is correct |