답안 #713592

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
713592 2023-03-22T15:04:22 Z MohamedFaresNebili 장난감 기차 (IOI17_train) C++14
100 / 100
1766 ms 1632 KB
#include <bits/stdc++.h>

        using namespace std;

        int N, M;
        vector<int> adj[5001], rev[5001];

        vector<int> who_wins(vector<int> A, vector<int> R,
                             vector<int> U, vector<int> V) {
            N = A.size(), M = U.size();
            for(int l = 0; l < M; l++) {
                int X = U[l], Y = V[l];
                adj[X].push_back(Y);
                rev[Y].push_back(X);
            }
            int _N = N;
            vector<int> res(N), G(N);
            while(_N--) {
                queue<int> Q;
                for(int l = 0; l < N; l++) res[l] = 0;
                for(int l = 0; l < N; l++) {
                    if(R[l] == 1) res[l] = 1, Q.push(l);
                    if(R[l]) continue;
                    if(A[l]) G[l] = 1;
                    else G[l] = adj[l].size();
                }

                while(!Q.empty()) {
                    int X = Q.front();
                    Q.pop(); res[X] = 1;
                    for(auto u : rev[X]) {
                        if(--G[u] == 0) Q.push(u);
                    }
                }

                for(int l = 0; l < N; l++) {
                    if(res[l] == 0) continue;
                    bool all = 1, one = 0;
                    for(auto u : adj[l]) {
                        all &= (1 - res[u]);
                        one |= (1 - res[u]);
                    }
                    if((A[l] && all) || (!A[l] && one))
                        res[l] = 0, R[l] = 0;
                }
            }
            return res;
        }
# 결과 실행 시간 메모리 Grader output
1 Correct 609 ms 1072 KB Output is correct
2 Correct 582 ms 1076 KB Output is correct
3 Correct 594 ms 1140 KB Output is correct
4 Correct 569 ms 1144 KB Output is correct
5 Correct 580 ms 1140 KB Output is correct
6 Correct 620 ms 1148 KB Output is correct
7 Correct 294 ms 1136 KB Output is correct
8 Correct 802 ms 1140 KB Output is correct
9 Correct 614 ms 1124 KB Output is correct
10 Correct 594 ms 1104 KB Output is correct
11 Correct 519 ms 1112 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 468 KB Output is correct
2 Correct 1 ms 544 KB Output is correct
3 Correct 1 ms 540 KB Output is correct
4 Correct 1 ms 544 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 1 ms 536 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 536 KB Output is correct
9 Correct 1 ms 468 KB Output is correct
10 Correct 1 ms 468 KB Output is correct
11 Correct 1 ms 468 KB Output is correct
12 Correct 1 ms 468 KB Output is correct
13 Correct 1 ms 468 KB Output is correct
14 Correct 1 ms 468 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Correct 1 ms 468 KB Output is correct
17 Correct 1 ms 480 KB Output is correct
18 Correct 1 ms 480 KB Output is correct
19 Correct 1 ms 480 KB Output is correct
20 Correct 1 ms 480 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 286 ms 1440 KB Output is correct
2 Correct 327 ms 1496 KB Output is correct
3 Correct 387 ms 1424 KB Output is correct
4 Correct 1341 ms 1380 KB Output is correct
5 Correct 1100 ms 1376 KB Output is correct
6 Correct 211 ms 1376 KB Output is correct
7 Correct 1419 ms 1372 KB Output is correct
8 Correct 760 ms 1364 KB Output is correct
9 Correct 211 ms 1336 KB Output is correct
10 Correct 1120 ms 1328 KB Output is correct
11 Correct 885 ms 1316 KB Output is correct
12 Correct 184 ms 1292 KB Output is correct
13 Correct 1501 ms 1488 KB Output is correct
14 Correct 1480 ms 1384 KB Output is correct
15 Correct 1505 ms 1384 KB Output is correct
16 Correct 1459 ms 1372 KB Output is correct
17 Correct 1521 ms 1380 KB Output is correct
18 Correct 382 ms 1116 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 975 ms 1236 KB Output is correct
2 Correct 1154 ms 1276 KB Output is correct
3 Correct 249 ms 1364 KB Output is correct
4 Correct 203 ms 1368 KB Output is correct
5 Correct 860 ms 1484 KB Output is correct
6 Correct 1180 ms 1340 KB Output is correct
7 Correct 1097 ms 1340 KB Output is correct
8 Correct 221 ms 1324 KB Output is correct
9 Correct 878 ms 1312 KB Output is correct
10 Correct 1224 ms 1384 KB Output is correct
11 Correct 1119 ms 1384 KB Output is correct
12 Correct 1268 ms 1380 KB Output is correct
13 Correct 948 ms 1380 KB Output is correct
14 Correct 1143 ms 1288 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1051 ms 1364 KB Output is correct
2 Correct 1766 ms 1584 KB Output is correct
3 Correct 1408 ms 1584 KB Output is correct
4 Correct 1574 ms 1492 KB Output is correct
5 Correct 2 ms 596 KB Output is correct
6 Correct 202 ms 1084 KB Output is correct
7 Correct 39 ms 1108 KB Output is correct
8 Correct 7 ms 1236 KB Output is correct
9 Correct 34 ms 1192 KB Output is correct
10 Correct 3 ms 724 KB Output is correct
11 Correct 70 ms 1184 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 609 ms 1072 KB Output is correct
2 Correct 582 ms 1076 KB Output is correct
3 Correct 594 ms 1140 KB Output is correct
4 Correct 569 ms 1144 KB Output is correct
5 Correct 580 ms 1140 KB Output is correct
6 Correct 620 ms 1148 KB Output is correct
7 Correct 294 ms 1136 KB Output is correct
8 Correct 802 ms 1140 KB Output is correct
9 Correct 614 ms 1124 KB Output is correct
10 Correct 594 ms 1104 KB Output is correct
11 Correct 519 ms 1112 KB Output is correct
12 Correct 0 ms 468 KB Output is correct
13 Correct 1 ms 544 KB Output is correct
14 Correct 1 ms 540 KB Output is correct
15 Correct 1 ms 544 KB Output is correct
16 Correct 1 ms 468 KB Output is correct
17 Correct 1 ms 536 KB Output is correct
18 Correct 1 ms 468 KB Output is correct
19 Correct 1 ms 536 KB Output is correct
20 Correct 1 ms 468 KB Output is correct
21 Correct 1 ms 468 KB Output is correct
22 Correct 1 ms 468 KB Output is correct
23 Correct 1 ms 468 KB Output is correct
24 Correct 1 ms 468 KB Output is correct
25 Correct 1 ms 468 KB Output is correct
26 Correct 1 ms 468 KB Output is correct
27 Correct 1 ms 468 KB Output is correct
28 Correct 1 ms 480 KB Output is correct
29 Correct 1 ms 480 KB Output is correct
30 Correct 1 ms 480 KB Output is correct
31 Correct 1 ms 480 KB Output is correct
32 Correct 286 ms 1440 KB Output is correct
33 Correct 327 ms 1496 KB Output is correct
34 Correct 387 ms 1424 KB Output is correct
35 Correct 1341 ms 1380 KB Output is correct
36 Correct 1100 ms 1376 KB Output is correct
37 Correct 211 ms 1376 KB Output is correct
38 Correct 1419 ms 1372 KB Output is correct
39 Correct 760 ms 1364 KB Output is correct
40 Correct 211 ms 1336 KB Output is correct
41 Correct 1120 ms 1328 KB Output is correct
42 Correct 885 ms 1316 KB Output is correct
43 Correct 184 ms 1292 KB Output is correct
44 Correct 1501 ms 1488 KB Output is correct
45 Correct 1480 ms 1384 KB Output is correct
46 Correct 1505 ms 1384 KB Output is correct
47 Correct 1459 ms 1372 KB Output is correct
48 Correct 1521 ms 1380 KB Output is correct
49 Correct 382 ms 1116 KB Output is correct
50 Correct 975 ms 1236 KB Output is correct
51 Correct 1154 ms 1276 KB Output is correct
52 Correct 249 ms 1364 KB Output is correct
53 Correct 203 ms 1368 KB Output is correct
54 Correct 860 ms 1484 KB Output is correct
55 Correct 1180 ms 1340 KB Output is correct
56 Correct 1097 ms 1340 KB Output is correct
57 Correct 221 ms 1324 KB Output is correct
58 Correct 878 ms 1312 KB Output is correct
59 Correct 1224 ms 1384 KB Output is correct
60 Correct 1119 ms 1384 KB Output is correct
61 Correct 1268 ms 1380 KB Output is correct
62 Correct 948 ms 1380 KB Output is correct
63 Correct 1143 ms 1288 KB Output is correct
64 Correct 1051 ms 1364 KB Output is correct
65 Correct 1766 ms 1584 KB Output is correct
66 Correct 1408 ms 1584 KB Output is correct
67 Correct 1574 ms 1492 KB Output is correct
68 Correct 2 ms 596 KB Output is correct
69 Correct 202 ms 1084 KB Output is correct
70 Correct 39 ms 1108 KB Output is correct
71 Correct 7 ms 1236 KB Output is correct
72 Correct 34 ms 1192 KB Output is correct
73 Correct 3 ms 724 KB Output is correct
74 Correct 70 ms 1184 KB Output is correct
75 Correct 285 ms 1600 KB Output is correct
76 Correct 348 ms 1620 KB Output is correct
77 Correct 392 ms 1632 KB Output is correct
78 Correct 393 ms 1620 KB Output is correct
79 Correct 398 ms 1620 KB Output is correct
80 Correct 1543 ms 1576 KB Output is correct
81 Correct 597 ms 1612 KB Output is correct
82 Correct 1006 ms 1572 KB Output is correct
83 Correct 1125 ms 1592 KB Output is correct
84 Correct 862 ms 1572 KB Output is correct
85 Correct 208 ms 1560 KB Output is correct
86 Correct 698 ms 1492 KB Output is correct
87 Correct 205 ms 1492 KB Output is correct
88 Correct 429 ms 1620 KB Output is correct
89 Correct 737 ms 1576 KB Output is correct
90 Correct 210 ms 1572 KB Output is correct
91 Correct 317 ms 1576 KB Output is correct
92 Correct 693 ms 1584 KB Output is correct
93 Correct 569 ms 1576 KB Output is correct
94 Correct 436 ms 1620 KB Output is correct
95 Correct 685 ms 1580 KB Output is correct
96 Correct 1169 ms 1496 KB Output is correct
97 Correct 466 ms 1592 KB Output is correct
98 Correct 593 ms 1560 KB Output is correct
99 Correct 494 ms 1548 KB Output is correct
100 Correct 383 ms 1236 KB Output is correct