답안 #263617

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
263617 2020-08-13T22:21:55 Z arayi 장난감 기차 (IOI17_train) C++17
100 / 100
1474 ms 4088 KB
#include "train.h"
#include <vector>
#include <queue>
#include <algorithm>
#define ad push_back
using namespace std;

const int N = 5e4 + 30;

int n;
vector <int> g[N], g1[N];
vector<int> col, r;
int sm[N], need[N];
void smth()
{
    for (int i = 0; i < n; i++)
	    sm[i] = 0, col[i] = 0;
    queue <int> q;
    for (int i = 0; i < n; i++)
	{
        if(r[i])
        {
            for(auto p : g1[i])
            {
                sm[p]++;
                if(sm[p] == need[p]) q.push(p);
            }
        }
	}
	while(!q.empty())
    {
        int v = q.front();
        q.pop();
        col[v] = 1;
        if(r[v]) continue;
        for(auto p : g1[v])
        {
            sm[p]++;
            if(sm[p] == need[p]) q.push(p);
        }
    }
}
vector <int> who_wins(vector<int> a, vector<int> R, vector<int> u, vector<int> v) {
	n = a.size();
	r = R;
	for (int i = 0; i < u.size(); i++)
	{
	    g[u[i]].ad(v[i]);
	    g1[v[i]].ad(u[i]);
	}
	for (int i = 0; i < n; i++)
	{
	    col.ad(0);
	    if(a[i]) need[i] = 1;
	    else need[i] = (int)g[i].size();
	}
	for (int i = 0; i < n; i++)
	{
	    smth();
	    for (int j = 0; j < n; j++)
	    {
	        if(r[j] && !col[j]) r[j] = 0;
	    }
	}
    return col;
}

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:46:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |  for (int i = 0; i < u.size(); i++)
      |                  ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 486 ms 3448 KB Output is correct
2 Correct 459 ms 3356 KB Output is correct
3 Correct 481 ms 3400 KB Output is correct
4 Correct 450 ms 3448 KB Output is correct
5 Correct 494 ms 3328 KB Output is correct
6 Correct 489 ms 3448 KB Output is correct
7 Correct 209 ms 3328 KB Output is correct
8 Correct 841 ms 3396 KB Output is correct
9 Correct 505 ms 3448 KB Output is correct
10 Correct 484 ms 3356 KB Output is correct
11 Correct 474 ms 3328 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2688 KB Output is correct
2 Correct 2 ms 2688 KB Output is correct
3 Correct 2 ms 2688 KB Output is correct
4 Correct 2 ms 2688 KB Output is correct
5 Correct 2 ms 2688 KB Output is correct
6 Correct 2 ms 2688 KB Output is correct
7 Correct 2 ms 2688 KB Output is correct
8 Correct 2 ms 2688 KB Output is correct
9 Correct 2 ms 2688 KB Output is correct
10 Correct 2 ms 2688 KB Output is correct
11 Correct 2 ms 2688 KB Output is correct
12 Correct 2 ms 2688 KB Output is correct
13 Correct 2 ms 2688 KB Output is correct
14 Correct 2 ms 2688 KB Output is correct
15 Correct 2 ms 2688 KB Output is correct
16 Correct 2 ms 2688 KB Output is correct
17 Correct 2 ms 2688 KB Output is correct
18 Correct 2 ms 2688 KB Output is correct
19 Correct 2 ms 2688 KB Output is correct
20 Correct 2 ms 2688 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 150 ms 3840 KB Output is correct
2 Correct 217 ms 3960 KB Output is correct
3 Correct 261 ms 3960 KB Output is correct
4 Correct 1278 ms 3832 KB Output is correct
5 Correct 806 ms 3840 KB Output is correct
6 Correct 107 ms 3840 KB Output is correct
7 Correct 1474 ms 3832 KB Output is correct
8 Correct 558 ms 3868 KB Output is correct
9 Correct 84 ms 3712 KB Output is correct
10 Correct 837 ms 3792 KB Output is correct
11 Correct 571 ms 3832 KB Output is correct
12 Correct 89 ms 3712 KB Output is correct
13 Correct 1207 ms 3960 KB Output is correct
14 Correct 1238 ms 3960 KB Output is correct
15 Correct 1239 ms 3960 KB Output is correct
16 Correct 1229 ms 3840 KB Output is correct
17 Correct 1230 ms 3960 KB Output is correct
18 Correct 316 ms 3456 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 996 ms 3584 KB Output is correct
2 Correct 839 ms 3712 KB Output is correct
3 Correct 129 ms 3832 KB Output is correct
4 Correct 85 ms 3832 KB Output is correct
5 Correct 620 ms 3828 KB Output is correct
6 Correct 970 ms 3812 KB Output is correct
7 Correct 890 ms 3832 KB Output is correct
8 Correct 108 ms 3712 KB Output is correct
9 Correct 904 ms 3832 KB Output is correct
10 Correct 1312 ms 3960 KB Output is correct
11 Correct 1143 ms 3960 KB Output is correct
12 Correct 1293 ms 3960 KB Output is correct
13 Correct 701 ms 3840 KB Output is correct
14 Correct 900 ms 3832 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 732 ms 3840 KB Output is correct
2 Correct 1259 ms 3960 KB Output is correct
3 Correct 1054 ms 3840 KB Output is correct
4 Correct 1251 ms 3728 KB Output is correct
5 Correct 3 ms 2688 KB Output is correct
6 Correct 79 ms 3328 KB Output is correct
7 Correct 33 ms 3328 KB Output is correct
8 Correct 8 ms 3488 KB Output is correct
9 Correct 29 ms 3328 KB Output is correct
10 Correct 5 ms 2944 KB Output is correct
11 Correct 59 ms 3328 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 486 ms 3448 KB Output is correct
2 Correct 459 ms 3356 KB Output is correct
3 Correct 481 ms 3400 KB Output is correct
4 Correct 450 ms 3448 KB Output is correct
5 Correct 494 ms 3328 KB Output is correct
6 Correct 489 ms 3448 KB Output is correct
7 Correct 209 ms 3328 KB Output is correct
8 Correct 841 ms 3396 KB Output is correct
9 Correct 505 ms 3448 KB Output is correct
10 Correct 484 ms 3356 KB Output is correct
11 Correct 474 ms 3328 KB Output is correct
12 Correct 2 ms 2688 KB Output is correct
13 Correct 2 ms 2688 KB Output is correct
14 Correct 2 ms 2688 KB Output is correct
15 Correct 2 ms 2688 KB Output is correct
16 Correct 2 ms 2688 KB Output is correct
17 Correct 2 ms 2688 KB Output is correct
18 Correct 2 ms 2688 KB Output is correct
19 Correct 2 ms 2688 KB Output is correct
20 Correct 2 ms 2688 KB Output is correct
21 Correct 2 ms 2688 KB Output is correct
22 Correct 2 ms 2688 KB Output is correct
23 Correct 2 ms 2688 KB Output is correct
24 Correct 2 ms 2688 KB Output is correct
25 Correct 2 ms 2688 KB Output is correct
26 Correct 2 ms 2688 KB Output is correct
27 Correct 2 ms 2688 KB Output is correct
28 Correct 2 ms 2688 KB Output is correct
29 Correct 2 ms 2688 KB Output is correct
30 Correct 2 ms 2688 KB Output is correct
31 Correct 2 ms 2688 KB Output is correct
32 Correct 150 ms 3840 KB Output is correct
33 Correct 217 ms 3960 KB Output is correct
34 Correct 261 ms 3960 KB Output is correct
35 Correct 1278 ms 3832 KB Output is correct
36 Correct 806 ms 3840 KB Output is correct
37 Correct 107 ms 3840 KB Output is correct
38 Correct 1474 ms 3832 KB Output is correct
39 Correct 558 ms 3868 KB Output is correct
40 Correct 84 ms 3712 KB Output is correct
41 Correct 837 ms 3792 KB Output is correct
42 Correct 571 ms 3832 KB Output is correct
43 Correct 89 ms 3712 KB Output is correct
44 Correct 1207 ms 3960 KB Output is correct
45 Correct 1238 ms 3960 KB Output is correct
46 Correct 1239 ms 3960 KB Output is correct
47 Correct 1229 ms 3840 KB Output is correct
48 Correct 1230 ms 3960 KB Output is correct
49 Correct 316 ms 3456 KB Output is correct
50 Correct 996 ms 3584 KB Output is correct
51 Correct 839 ms 3712 KB Output is correct
52 Correct 129 ms 3832 KB Output is correct
53 Correct 85 ms 3832 KB Output is correct
54 Correct 620 ms 3828 KB Output is correct
55 Correct 970 ms 3812 KB Output is correct
56 Correct 890 ms 3832 KB Output is correct
57 Correct 108 ms 3712 KB Output is correct
58 Correct 904 ms 3832 KB Output is correct
59 Correct 1312 ms 3960 KB Output is correct
60 Correct 1143 ms 3960 KB Output is correct
61 Correct 1293 ms 3960 KB Output is correct
62 Correct 701 ms 3840 KB Output is correct
63 Correct 900 ms 3832 KB Output is correct
64 Correct 732 ms 3840 KB Output is correct
65 Correct 1259 ms 3960 KB Output is correct
66 Correct 1054 ms 3840 KB Output is correct
67 Correct 1251 ms 3728 KB Output is correct
68 Correct 3 ms 2688 KB Output is correct
69 Correct 79 ms 3328 KB Output is correct
70 Correct 33 ms 3328 KB Output is correct
71 Correct 8 ms 3488 KB Output is correct
72 Correct 29 ms 3328 KB Output is correct
73 Correct 5 ms 2944 KB Output is correct
74 Correct 59 ms 3328 KB Output is correct
75 Correct 170 ms 3840 KB Output is correct
76 Correct 209 ms 3884 KB Output is correct
77 Correct 262 ms 3960 KB Output is correct
78 Correct 259 ms 3840 KB Output is correct
79 Correct 260 ms 3960 KB Output is correct
80 Correct 1424 ms 3828 KB Output is correct
81 Correct 422 ms 3832 KB Output is correct
82 Correct 662 ms 3840 KB Output is correct
83 Correct 819 ms 3960 KB Output is correct
84 Correct 565 ms 3832 KB Output is correct
85 Correct 97 ms 3832 KB Output is correct
86 Correct 515 ms 3840 KB Output is correct
87 Correct 103 ms 3832 KB Output is correct
88 Correct 261 ms 3840 KB Output is correct
89 Correct 597 ms 3960 KB Output is correct
90 Correct 96 ms 3840 KB Output is correct
91 Correct 167 ms 3840 KB Output is correct
92 Correct 496 ms 4088 KB Output is correct
93 Correct 350 ms 3960 KB Output is correct
94 Correct 235 ms 3840 KB Output is correct
95 Correct 449 ms 3844 KB Output is correct
96 Correct 885 ms 3832 KB Output is correct
97 Correct 360 ms 3840 KB Output is correct
98 Correct 428 ms 3832 KB Output is correct
99 Correct 400 ms 3712 KB Output is correct
100 Correct 313 ms 3456 KB Output is correct