Submission #53439

# Submission time Handle Problem Language Result Execution time Memory
53439 2018-06-30T02:44:18 Z ainta Toy Train (IOI17_train) C++17
49 / 100
1876 ms 1368 KB
#include "train.h"
#include<cstdio>
#include<algorithm>
using namespace std;

int n, m, D[5010], TD[5010], U[5010];

vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u, vector<int> v) {
	n = a.size();
	m = u.size();
	int i, j, k;
	for (i = 0; i < n; i++) {
		if (r[i] == 1)D[i] = 1;
		else D[i] = 0;
        if (a[i] == 1)TD[i] = 0;
        else TD[i] = 1e9;
	}
	for (i = 0; i < 10003; i++) {
		for (j = 0; j < m; j++) {
			if (a[u[j]] == 1) {
				TD[u[j]] = max(TD[u[j]], r[u[j]] + D[v[j]]);
			}
			else {
				TD[u[j]] = min(TD[u[j]], r[u[j]] + D[v[j]]);
			}
		}
		for (j = 0; j < n; j++) {
			if (i == 5002)U[j] = TD[j];
			D[j] = TD[j];
			if (a[j] == 1)TD[j] = 0;
			else TD[j] = 1e9;
		}
	}
	vector<int>res(n);
	for (j = 0; j < n; j++) {
		if (D[j] != U[j])res[j] = 1;
		else res[j] = 0;
	}
	return res;
}

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:11:12: warning: unused variable 'k' [-Wunused-variable]
  int i, j, k;
            ^
# Verdict Execution time Memory Grader output
1 Correct 603 ms 552 KB Output is correct
2 Correct 670 ms 612 KB Output is correct
3 Correct 593 ms 688 KB Output is correct
4 Correct 603 ms 688 KB Output is correct
5 Correct 598 ms 688 KB Output is correct
6 Correct 654 ms 740 KB Output is correct
7 Correct 334 ms 828 KB Output is correct
8 Correct 321 ms 956 KB Output is correct
9 Correct 608 ms 956 KB Output is correct
10 Correct 567 ms 956 KB Output is correct
11 Correct 474 ms 956 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 956 KB Output is correct
2 Correct 4 ms 956 KB Output is correct
3 Correct 3 ms 956 KB Output is correct
4 Correct 6 ms 956 KB Output is correct
5 Correct 2 ms 956 KB Output is correct
6 Correct 3 ms 956 KB Output is correct
7 Correct 3 ms 956 KB Output is correct
8 Correct 4 ms 956 KB Output is correct
9 Correct 4 ms 956 KB Output is correct
10 Correct 3 ms 956 KB Output is correct
11 Correct 5 ms 956 KB Output is correct
12 Correct 4 ms 956 KB Output is correct
13 Correct 3 ms 956 KB Output is correct
14 Correct 2 ms 956 KB Output is correct
15 Correct 2 ms 956 KB Output is correct
16 Correct 2 ms 956 KB Output is correct
17 Correct 2 ms 956 KB Output is correct
18 Correct 3 ms 956 KB Output is correct
19 Correct 4 ms 956 KB Output is correct
20 Correct 3 ms 956 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 661 ms 1196 KB Output is correct
2 Correct 694 ms 1196 KB Output is correct
3 Correct 545 ms 1324 KB Output is correct
4 Correct 788 ms 1324 KB Output is correct
5 Correct 785 ms 1324 KB Output is correct
6 Correct 756 ms 1324 KB Output is correct
7 Correct 752 ms 1336 KB Output is correct
8 Correct 740 ms 1336 KB Output is correct
9 Correct 630 ms 1336 KB Output is correct
10 Correct 736 ms 1336 KB Output is correct
11 Correct 693 ms 1336 KB Output is correct
12 Correct 667 ms 1336 KB Output is correct
13 Correct 782 ms 1336 KB Output is correct
14 Correct 765 ms 1340 KB Output is correct
15 Correct 832 ms 1340 KB Output is correct
16 Correct 817 ms 1340 KB Output is correct
17 Correct 769 ms 1340 KB Output is correct
18 Correct 427 ms 1340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 612 ms 1340 KB Output is correct
2 Correct 673 ms 1340 KB Output is correct
3 Correct 770 ms 1368 KB Output is correct
4 Correct 764 ms 1368 KB Output is correct
5 Correct 756 ms 1368 KB Output is correct
6 Correct 698 ms 1368 KB Output is correct
7 Correct 708 ms 1368 KB Output is correct
8 Correct 687 ms 1368 KB Output is correct
9 Correct 724 ms 1368 KB Output is correct
10 Correct 833 ms 1368 KB Output is correct
11 Correct 759 ms 1368 KB Output is correct
12 Correct 762 ms 1368 KB Output is correct
13 Correct 741 ms 1368 KB Output is correct
14 Correct 753 ms 1368 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1153 ms 1368 KB Output is correct
2 Correct 996 ms 1368 KB Output is correct
3 Correct 1876 ms 1368 KB Output is correct
4 Correct 1559 ms 1368 KB Output is correct
5 Correct 75 ms 1368 KB Output is correct
6 Correct 628 ms 1368 KB Output is correct
7 Correct 1185 ms 1368 KB Output is correct
8 Correct 1576 ms 1368 KB Output is correct
9 Correct 1433 ms 1368 KB Output is correct
10 Correct 268 ms 1368 KB Output is correct
11 Correct 995 ms 1368 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 603 ms 552 KB Output is correct
2 Correct 670 ms 612 KB Output is correct
3 Correct 593 ms 688 KB Output is correct
4 Correct 603 ms 688 KB Output is correct
5 Correct 598 ms 688 KB Output is correct
6 Correct 654 ms 740 KB Output is correct
7 Correct 334 ms 828 KB Output is correct
8 Correct 321 ms 956 KB Output is correct
9 Correct 608 ms 956 KB Output is correct
10 Correct 567 ms 956 KB Output is correct
11 Correct 474 ms 956 KB Output is correct
12 Correct 5 ms 956 KB Output is correct
13 Correct 4 ms 956 KB Output is correct
14 Correct 3 ms 956 KB Output is correct
15 Correct 6 ms 956 KB Output is correct
16 Correct 2 ms 956 KB Output is correct
17 Correct 3 ms 956 KB Output is correct
18 Correct 3 ms 956 KB Output is correct
19 Correct 4 ms 956 KB Output is correct
20 Correct 4 ms 956 KB Output is correct
21 Correct 3 ms 956 KB Output is correct
22 Correct 5 ms 956 KB Output is correct
23 Correct 4 ms 956 KB Output is correct
24 Correct 3 ms 956 KB Output is correct
25 Correct 2 ms 956 KB Output is correct
26 Correct 2 ms 956 KB Output is correct
27 Correct 2 ms 956 KB Output is correct
28 Correct 2 ms 956 KB Output is correct
29 Correct 3 ms 956 KB Output is correct
30 Correct 4 ms 956 KB Output is correct
31 Correct 3 ms 956 KB Output is correct
32 Correct 661 ms 1196 KB Output is correct
33 Correct 694 ms 1196 KB Output is correct
34 Correct 545 ms 1324 KB Output is correct
35 Correct 788 ms 1324 KB Output is correct
36 Correct 785 ms 1324 KB Output is correct
37 Correct 756 ms 1324 KB Output is correct
38 Correct 752 ms 1336 KB Output is correct
39 Correct 740 ms 1336 KB Output is correct
40 Correct 630 ms 1336 KB Output is correct
41 Correct 736 ms 1336 KB Output is correct
42 Correct 693 ms 1336 KB Output is correct
43 Correct 667 ms 1336 KB Output is correct
44 Correct 782 ms 1336 KB Output is correct
45 Correct 765 ms 1340 KB Output is correct
46 Correct 832 ms 1340 KB Output is correct
47 Correct 817 ms 1340 KB Output is correct
48 Correct 769 ms 1340 KB Output is correct
49 Correct 427 ms 1340 KB Output is correct
50 Correct 612 ms 1340 KB Output is correct
51 Correct 673 ms 1340 KB Output is correct
52 Correct 770 ms 1368 KB Output is correct
53 Correct 764 ms 1368 KB Output is correct
54 Correct 756 ms 1368 KB Output is correct
55 Correct 698 ms 1368 KB Output is correct
56 Correct 708 ms 1368 KB Output is correct
57 Correct 687 ms 1368 KB Output is correct
58 Correct 724 ms 1368 KB Output is correct
59 Correct 833 ms 1368 KB Output is correct
60 Correct 759 ms 1368 KB Output is correct
61 Correct 762 ms 1368 KB Output is correct
62 Correct 741 ms 1368 KB Output is correct
63 Correct 753 ms 1368 KB Output is correct
64 Correct 1153 ms 1368 KB Output is correct
65 Correct 996 ms 1368 KB Output is correct
66 Correct 1876 ms 1368 KB Output is correct
67 Correct 1559 ms 1368 KB Output is correct
68 Correct 75 ms 1368 KB Output is correct
69 Correct 628 ms 1368 KB Output is correct
70 Correct 1185 ms 1368 KB Output is correct
71 Correct 1576 ms 1368 KB Output is correct
72 Correct 1433 ms 1368 KB Output is correct
73 Correct 268 ms 1368 KB Output is correct
74 Correct 995 ms 1368 KB Output is correct
75 Correct 597 ms 1368 KB Output is correct
76 Correct 707 ms 1368 KB Output is correct
77 Correct 613 ms 1368 KB Output is correct
78 Correct 738 ms 1368 KB Output is correct
79 Correct 709 ms 1368 KB Output is correct
80 Correct 1756 ms 1368 KB Output is correct
81 Correct 1827 ms 1368 KB Output is correct
82 Correct 1505 ms 1368 KB Output is correct
83 Correct 870 ms 1368 KB Output is correct
84 Correct 881 ms 1368 KB Output is correct
85 Correct 904 ms 1368 KB Output is correct
86 Correct 806 ms 1368 KB Output is correct
87 Correct 840 ms 1368 KB Output is correct
88 Correct 1798 ms 1368 KB Output is correct
89 Correct 1037 ms 1368 KB Output is correct
90 Correct 1768 ms 1368 KB Output is correct
91 Correct 887 ms 1368 KB Output is correct
92 Correct 1074 ms 1368 KB Output is correct
93 Correct 1108 ms 1368 KB Output is correct
94 Correct 1799 ms 1368 KB Output is correct
95 Correct 1723 ms 1368 KB Output is correct
96 Incorrect 929 ms 1368 KB 3rd lines differ - on the 5th token, expected: '0', found: '1'
97 Halted 0 ms 0 KB -