답안 #99216

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
99216 2019-03-01T18:17:45 Z eriksuenderhauf 장난감 기차 (IOI17_train) C++11
100 / 100
536 ms 1532 KB
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
//#include "train.h"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define enl printf("\n")
#define case(t) printf("Case #%d: ", (t))
#define ni(n) scanf("%d", &(n))
#define nl(n) scanf("%I64d", &(n))
#define nai(a, n) for (int i = 0; i < (n); i++) ni(a[i])
#define nal(a, n) for (int i = 0; i < (n); i++) nl(a[i])
#define pri(n) printf("%d\n", (n))
#define prl(n) printf("%I64d\n", (n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define vii vector<pii>
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef cc_hash_table<int,int,hash<int>> ht;
const double pi = acos(-1);
const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const int MAXN = 5e3 + 5;
const double eps = 1e-9;
vi adj[MAXN];
int deg[MAXN], cnt[MAXN];

void dfs(int u, vi& r) {
	for (int v: adj[u])
    {
        cnt[v]--;
        if (r[v] == 1 || cnt[v] != 0)
            continue;
		dfs(v, r);
	}
}

vi who_wins(vi a, vi r, vi u, vi v) {
	int n = a.size(), m = u.size();
	for (int i = 0; i < m; i++)
        adj[v[i]].pb(u[i]), deg[u[i]]++;
	vi ans;
	for (int i = 0; i < n; i++) ans.pb(1);
	while (1)
    {
        for (int i = 0; i < n; i++)
            cnt[i] = a[i] == 1 ? 1 : deg[i];
        for (int i = 0; i < n; i++)
            if (r[i] == 1 && ans[i] == 1)
                dfs(i, r);
        int fl = 0;
        for (int i = 0; i < n; i++)
            if (r[i] == 1 && ans[i] == 1 && cnt[i] > 0)
                ans[i] = 0, fl = 1;
        if (fl == 0)
            break;
	}
	for (int i = 0; i < n; i++)
        ans[i] &= cnt[i] <= 0;
	return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 1024 KB Output is correct
2 Correct 9 ms 1024 KB Output is correct
3 Correct 8 ms 1024 KB Output is correct
4 Correct 9 ms 1024 KB Output is correct
5 Correct 8 ms 1024 KB Output is correct
6 Correct 8 ms 1024 KB Output is correct
7 Correct 8 ms 1024 KB Output is correct
8 Correct 11 ms 896 KB Output is correct
9 Correct 6 ms 896 KB Output is correct
10 Correct 6 ms 896 KB Output is correct
11 Correct 6 ms 896 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 512 KB Output is correct
2 Correct 2 ms 512 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 3 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 3 ms 384 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 2 ms 512 KB Output is correct
14 Correct 2 ms 512 KB Output is correct
15 Correct 3 ms 512 KB Output is correct
16 Correct 2 ms 256 KB Output is correct
17 Correct 2 ms 384 KB Output is correct
18 Correct 2 ms 384 KB Output is correct
19 Correct 2 ms 384 KB Output is correct
20 Correct 2 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 78 ms 1408 KB Output is correct
2 Correct 121 ms 1436 KB Output is correct
3 Correct 177 ms 1408 KB Output is correct
4 Correct 12 ms 1408 KB Output is correct
5 Correct 14 ms 1408 KB Output is correct
6 Correct 12 ms 1408 KB Output is correct
7 Correct 9 ms 1280 KB Output is correct
8 Correct 11 ms 1408 KB Output is correct
9 Correct 15 ms 1280 KB Output is correct
10 Correct 9 ms 1280 KB Output is correct
11 Correct 8 ms 1280 KB Output is correct
12 Correct 10 ms 1280 KB Output is correct
13 Correct 12 ms 1436 KB Output is correct
14 Correct 10 ms 1408 KB Output is correct
15 Correct 9 ms 1476 KB Output is correct
16 Correct 11 ms 1408 KB Output is correct
17 Correct 11 ms 1408 KB Output is correct
18 Correct 297 ms 1144 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 1152 KB Output is correct
2 Correct 11 ms 1280 KB Output is correct
3 Correct 10 ms 1280 KB Output is correct
4 Correct 10 ms 1280 KB Output is correct
5 Correct 9 ms 1408 KB Output is correct
6 Correct 9 ms 1280 KB Output is correct
7 Correct 14 ms 1288 KB Output is correct
8 Correct 17 ms 1280 KB Output is correct
9 Correct 11 ms 1272 KB Output is correct
10 Correct 12 ms 1280 KB Output is correct
11 Correct 9 ms 1408 KB Output is correct
12 Correct 12 ms 1408 KB Output is correct
13 Correct 11 ms 1280 KB Output is correct
14 Correct 11 ms 1280 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 1408 KB Output is correct
2 Correct 19 ms 1408 KB Output is correct
3 Correct 15 ms 1408 KB Output is correct
4 Correct 9 ms 1280 KB Output is correct
5 Correct 3 ms 512 KB Output is correct
6 Correct 6 ms 896 KB Output is correct
7 Correct 7 ms 1024 KB Output is correct
8 Correct 8 ms 1024 KB Output is correct
9 Correct 7 ms 1024 KB Output is correct
10 Correct 3 ms 640 KB Output is correct
11 Correct 8 ms 896 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 1024 KB Output is correct
2 Correct 9 ms 1024 KB Output is correct
3 Correct 8 ms 1024 KB Output is correct
4 Correct 9 ms 1024 KB Output is correct
5 Correct 8 ms 1024 KB Output is correct
6 Correct 8 ms 1024 KB Output is correct
7 Correct 8 ms 1024 KB Output is correct
8 Correct 11 ms 896 KB Output is correct
9 Correct 6 ms 896 KB Output is correct
10 Correct 6 ms 896 KB Output is correct
11 Correct 6 ms 896 KB Output is correct
12 Correct 2 ms 512 KB Output is correct
13 Correct 2 ms 512 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 2 ms 384 KB Output is correct
17 Correct 2 ms 384 KB Output is correct
18 Correct 2 ms 384 KB Output is correct
19 Correct 2 ms 384 KB Output is correct
20 Correct 3 ms 384 KB Output is correct
21 Correct 2 ms 384 KB Output is correct
22 Correct 3 ms 384 KB Output is correct
23 Correct 2 ms 384 KB Output is correct
24 Correct 2 ms 512 KB Output is correct
25 Correct 2 ms 512 KB Output is correct
26 Correct 3 ms 512 KB Output is correct
27 Correct 2 ms 256 KB Output is correct
28 Correct 2 ms 384 KB Output is correct
29 Correct 2 ms 384 KB Output is correct
30 Correct 2 ms 384 KB Output is correct
31 Correct 2 ms 384 KB Output is correct
32 Correct 78 ms 1408 KB Output is correct
33 Correct 121 ms 1436 KB Output is correct
34 Correct 177 ms 1408 KB Output is correct
35 Correct 12 ms 1408 KB Output is correct
36 Correct 14 ms 1408 KB Output is correct
37 Correct 12 ms 1408 KB Output is correct
38 Correct 9 ms 1280 KB Output is correct
39 Correct 11 ms 1408 KB Output is correct
40 Correct 15 ms 1280 KB Output is correct
41 Correct 9 ms 1280 KB Output is correct
42 Correct 8 ms 1280 KB Output is correct
43 Correct 10 ms 1280 KB Output is correct
44 Correct 12 ms 1436 KB Output is correct
45 Correct 10 ms 1408 KB Output is correct
46 Correct 9 ms 1476 KB Output is correct
47 Correct 11 ms 1408 KB Output is correct
48 Correct 11 ms 1408 KB Output is correct
49 Correct 297 ms 1144 KB Output is correct
50 Correct 10 ms 1152 KB Output is correct
51 Correct 11 ms 1280 KB Output is correct
52 Correct 10 ms 1280 KB Output is correct
53 Correct 10 ms 1280 KB Output is correct
54 Correct 9 ms 1408 KB Output is correct
55 Correct 9 ms 1280 KB Output is correct
56 Correct 14 ms 1288 KB Output is correct
57 Correct 17 ms 1280 KB Output is correct
58 Correct 11 ms 1272 KB Output is correct
59 Correct 12 ms 1280 KB Output is correct
60 Correct 9 ms 1408 KB Output is correct
61 Correct 12 ms 1408 KB Output is correct
62 Correct 11 ms 1280 KB Output is correct
63 Correct 11 ms 1280 KB Output is correct
64 Correct 13 ms 1408 KB Output is correct
65 Correct 19 ms 1408 KB Output is correct
66 Correct 15 ms 1408 KB Output is correct
67 Correct 9 ms 1280 KB Output is correct
68 Correct 3 ms 512 KB Output is correct
69 Correct 6 ms 896 KB Output is correct
70 Correct 7 ms 1024 KB Output is correct
71 Correct 8 ms 1024 KB Output is correct
72 Correct 7 ms 1024 KB Output is correct
73 Correct 3 ms 640 KB Output is correct
74 Correct 8 ms 896 KB Output is correct
75 Correct 78 ms 1528 KB Output is correct
76 Correct 136 ms 1532 KB Output is correct
77 Correct 216 ms 1500 KB Output is correct
78 Correct 219 ms 1528 KB Output is correct
79 Correct 230 ms 1436 KB Output is correct
80 Correct 10 ms 1408 KB Output is correct
81 Correct 10 ms 1408 KB Output is correct
82 Correct 12 ms 1408 KB Output is correct
83 Correct 16 ms 1408 KB Output is correct
84 Correct 12 ms 1408 KB Output is correct
85 Correct 10 ms 1408 KB Output is correct
86 Correct 12 ms 1408 KB Output is correct
87 Correct 9 ms 1280 KB Output is correct
88 Correct 14 ms 1280 KB Output is correct
89 Correct 9 ms 1408 KB Output is correct
90 Correct 18 ms 1280 KB Output is correct
91 Correct 24 ms 1408 KB Output is correct
92 Correct 36 ms 1408 KB Output is correct
93 Correct 25 ms 1376 KB Output is correct
94 Correct 37 ms 1400 KB Output is correct
95 Correct 43 ms 1408 KB Output is correct
96 Correct 69 ms 1280 KB Output is correct
97 Correct 298 ms 1396 KB Output is correct
98 Correct 456 ms 1324 KB Output is correct
99 Correct 536 ms 1400 KB Output is correct
100 Correct 285 ms 1024 KB Output is correct