Submission #53200

# Submission time Handle Problem Language Result Execution time Memory
53200 2018-06-29T01:45:56 Z WA_TLE Toy Train (IOI17_train) C++14
100 / 100
703 ms 11772 KB
#include "train.h"
#include<vector>
#include<queue>
using namespace std;
#define pub push_back
std::vector<int> who_wins(std::vector<int> a, std::vector<int> r, std::vector<int> u, std::vector<int> v) {
	int i,j,n=a.size(),m=u.size();
	vector<vector<int>>go(n);
	vector<vector<int>>rev(n);
	//サイクルになりうるのを求める
	for(i=0;i<m;i++){
		go[u[i]].pub(v[i]);
		rev[v[i]].pub(u[i]);
	}
	
	//cirが0以下ならチャー駅に行ける(勝つとは言ってない)
	//0より大きいなら即Bの勝ち
	vector<int>ans(n,1);
	while(-1){
		vector<int>cir(n);
		queue<int>que;
		for(i=0;i<n;i++){
			if(r[i]&&ans[i]){que.push(i);}
			else if(a[i]){cir[i]=1;}
			else{cir[i]=go[i].size();}
		}
		while(que.size()>0){
			int ter=que.front();
			que.pop();
			for(auto it:rev[ter]){
				if(cir[it]==1){que.push(it);}
				cir[it]--;
			}
		}
		vector<int>bwi(n);
		for(i=0;i<n;i++){
			if(cir[i]>0){que.push(i);}
			else if(a[i]){bwi[i]=go[i].size();}
			else{bwi[i]=1;}
		}
		while(que.size()>0){
			int ter=que.front();
			que.pop();
			for(auto it:rev[ter]){
				if(bwi[it]==1){que.push(it);}
				bwi[it]--;
			}
		}
		vector<int>gen(n);
		for(i=0;i<n;i++){if(bwi[i]>0){gen[i]=1;}}
		if(ans==gen){return gen;}
		else{ans=move(gen);}
	}
}

Compilation message

train.cpp: In function 'std::vector<int> who_wins(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
train.cpp:7:8: warning: unused variable 'j' [-Wunused-variable]
  int i,j,n=a.size(),m=u.size();
        ^
# Verdict Execution time Memory Grader output
1 Correct 9 ms 1144 KB Output is correct
2 Correct 9 ms 1256 KB Output is correct
3 Correct 8 ms 1408 KB Output is correct
4 Correct 8 ms 1556 KB Output is correct
5 Correct 9 ms 1596 KB Output is correct
6 Correct 7 ms 1676 KB Output is correct
7 Correct 7 ms 2004 KB Output is correct
8 Correct 8 ms 2004 KB Output is correct
9 Correct 7 ms 2004 KB Output is correct
10 Correct 7 ms 2192 KB Output is correct
11 Correct 6 ms 2192 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2192 KB Output is correct
2 Correct 2 ms 2192 KB Output is correct
3 Correct 2 ms 2192 KB Output is correct
4 Correct 2 ms 2192 KB Output is correct
5 Correct 2 ms 2192 KB Output is correct
6 Correct 2 ms 2192 KB Output is correct
7 Correct 2 ms 2192 KB Output is correct
8 Correct 2 ms 2192 KB Output is correct
9 Correct 2 ms 2192 KB Output is correct
10 Correct 2 ms 2192 KB Output is correct
11 Correct 2 ms 2192 KB Output is correct
12 Correct 2 ms 2192 KB Output is correct
13 Correct 2 ms 2192 KB Output is correct
14 Correct 2 ms 2192 KB Output is correct
15 Correct 2 ms 2192 KB Output is correct
16 Correct 2 ms 2192 KB Output is correct
17 Correct 2 ms 2192 KB Output is correct
18 Correct 3 ms 2192 KB Output is correct
19 Correct 2 ms 2192 KB Output is correct
20 Correct 2 ms 2192 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 95 ms 2816 KB Output is correct
2 Correct 204 ms 2944 KB Output is correct
3 Correct 296 ms 3300 KB Output is correct
4 Correct 12 ms 3376 KB Output is correct
5 Correct 13 ms 3676 KB Output is correct
6 Correct 12 ms 3760 KB Output is correct
7 Correct 11 ms 4000 KB Output is correct
8 Correct 11 ms 4292 KB Output is correct
9 Correct 10 ms 4380 KB Output is correct
10 Correct 11 ms 4700 KB Output is correct
11 Correct 12 ms 4700 KB Output is correct
12 Correct 10 ms 4888 KB Output is correct
13 Correct 20 ms 5180 KB Output is correct
14 Correct 14 ms 5472 KB Output is correct
15 Correct 11 ms 5688 KB Output is correct
16 Correct 12 ms 5768 KB Output is correct
17 Correct 14 ms 5924 KB Output is correct
18 Correct 474 ms 5964 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 5964 KB Output is correct
2 Correct 10 ms 5964 KB Output is correct
3 Correct 11 ms 6080 KB Output is correct
4 Correct 13 ms 6080 KB Output is correct
5 Correct 22 ms 6080 KB Output is correct
6 Correct 13 ms 6108 KB Output is correct
7 Correct 11 ms 6108 KB Output is correct
8 Correct 11 ms 6128 KB Output is correct
9 Correct 10 ms 6128 KB Output is correct
10 Correct 12 ms 6128 KB Output is correct
11 Correct 16 ms 6128 KB Output is correct
12 Correct 12 ms 6128 KB Output is correct
13 Correct 11 ms 6128 KB Output is correct
14 Correct 18 ms 6128 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 6128 KB Output is correct
2 Correct 11 ms 6128 KB Output is correct
3 Correct 14 ms 6128 KB Output is correct
4 Correct 12 ms 6128 KB Output is correct
5 Correct 3 ms 6128 KB Output is correct
6 Correct 7 ms 6128 KB Output is correct
7 Correct 10 ms 6128 KB Output is correct
8 Correct 7 ms 6128 KB Output is correct
9 Correct 7 ms 6128 KB Output is correct
10 Correct 4 ms 6128 KB Output is correct
11 Correct 11 ms 6128 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 1144 KB Output is correct
2 Correct 9 ms 1256 KB Output is correct
3 Correct 8 ms 1408 KB Output is correct
4 Correct 8 ms 1556 KB Output is correct
5 Correct 9 ms 1596 KB Output is correct
6 Correct 7 ms 1676 KB Output is correct
7 Correct 7 ms 2004 KB Output is correct
8 Correct 8 ms 2004 KB Output is correct
9 Correct 7 ms 2004 KB Output is correct
10 Correct 7 ms 2192 KB Output is correct
11 Correct 6 ms 2192 KB Output is correct
12 Correct 2 ms 2192 KB Output is correct
13 Correct 2 ms 2192 KB Output is correct
14 Correct 2 ms 2192 KB Output is correct
15 Correct 2 ms 2192 KB Output is correct
16 Correct 2 ms 2192 KB Output is correct
17 Correct 2 ms 2192 KB Output is correct
18 Correct 2 ms 2192 KB Output is correct
19 Correct 2 ms 2192 KB Output is correct
20 Correct 2 ms 2192 KB Output is correct
21 Correct 2 ms 2192 KB Output is correct
22 Correct 2 ms 2192 KB Output is correct
23 Correct 2 ms 2192 KB Output is correct
24 Correct 2 ms 2192 KB Output is correct
25 Correct 2 ms 2192 KB Output is correct
26 Correct 2 ms 2192 KB Output is correct
27 Correct 2 ms 2192 KB Output is correct
28 Correct 2 ms 2192 KB Output is correct
29 Correct 3 ms 2192 KB Output is correct
30 Correct 2 ms 2192 KB Output is correct
31 Correct 2 ms 2192 KB Output is correct
32 Correct 95 ms 2816 KB Output is correct
33 Correct 204 ms 2944 KB Output is correct
34 Correct 296 ms 3300 KB Output is correct
35 Correct 12 ms 3376 KB Output is correct
36 Correct 13 ms 3676 KB Output is correct
37 Correct 12 ms 3760 KB Output is correct
38 Correct 11 ms 4000 KB Output is correct
39 Correct 11 ms 4292 KB Output is correct
40 Correct 10 ms 4380 KB Output is correct
41 Correct 11 ms 4700 KB Output is correct
42 Correct 12 ms 4700 KB Output is correct
43 Correct 10 ms 4888 KB Output is correct
44 Correct 20 ms 5180 KB Output is correct
45 Correct 14 ms 5472 KB Output is correct
46 Correct 11 ms 5688 KB Output is correct
47 Correct 12 ms 5768 KB Output is correct
48 Correct 14 ms 5924 KB Output is correct
49 Correct 474 ms 5964 KB Output is correct
50 Correct 10 ms 5964 KB Output is correct
51 Correct 10 ms 5964 KB Output is correct
52 Correct 11 ms 6080 KB Output is correct
53 Correct 13 ms 6080 KB Output is correct
54 Correct 22 ms 6080 KB Output is correct
55 Correct 13 ms 6108 KB Output is correct
56 Correct 11 ms 6108 KB Output is correct
57 Correct 11 ms 6128 KB Output is correct
58 Correct 10 ms 6128 KB Output is correct
59 Correct 12 ms 6128 KB Output is correct
60 Correct 16 ms 6128 KB Output is correct
61 Correct 12 ms 6128 KB Output is correct
62 Correct 11 ms 6128 KB Output is correct
63 Correct 18 ms 6128 KB Output is correct
64 Correct 12 ms 6128 KB Output is correct
65 Correct 11 ms 6128 KB Output is correct
66 Correct 14 ms 6128 KB Output is correct
67 Correct 12 ms 6128 KB Output is correct
68 Correct 3 ms 6128 KB Output is correct
69 Correct 7 ms 6128 KB Output is correct
70 Correct 10 ms 6128 KB Output is correct
71 Correct 7 ms 6128 KB Output is correct
72 Correct 7 ms 6128 KB Output is correct
73 Correct 4 ms 6128 KB Output is correct
74 Correct 11 ms 6128 KB Output is correct
75 Correct 183 ms 6648 KB Output is correct
76 Correct 245 ms 6916 KB Output is correct
77 Correct 389 ms 7108 KB Output is correct
78 Correct 347 ms 7364 KB Output is correct
79 Correct 338 ms 7700 KB Output is correct
80 Correct 12 ms 7700 KB Output is correct
81 Correct 20 ms 7860 KB Output is correct
82 Correct 12 ms 8128 KB Output is correct
83 Correct 12 ms 8276 KB Output is correct
84 Correct 21 ms 8484 KB Output is correct
85 Correct 12 ms 8692 KB Output is correct
86 Correct 13 ms 8852 KB Output is correct
87 Correct 12 ms 9128 KB Output is correct
88 Correct 15 ms 9412 KB Output is correct
89 Correct 12 ms 9636 KB Output is correct
90 Correct 18 ms 9848 KB Output is correct
91 Correct 17 ms 9924 KB Output is correct
92 Correct 28 ms 10196 KB Output is correct
93 Correct 27 ms 10332 KB Output is correct
94 Correct 30 ms 10612 KB Output is correct
95 Correct 30 ms 10772 KB Output is correct
96 Correct 84 ms 10852 KB Output is correct
97 Correct 425 ms 11584 KB Output is correct
98 Correct 651 ms 11584 KB Output is correct
99 Correct 703 ms 11592 KB Output is correct
100 Correct 481 ms 11772 KB Output is correct