답안 #733686

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
733686 2023-05-01T08:03:33 Z t6twotwo 장난감 기차 (IOI17_train) C++17
15 / 100
2000 ms 1364 KB
#include "train.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> who_wins(vector<int> A, vector<int> R, vector<int> U, vector<int> V) {
    int N = A.size();
    int M = U.size();
    vector<vector<int>> adj(N);
    for (int i = 0; i < M; i++) {
        adj[U[i]].push_back(V[i]);
    }
    vector<int> ans(N);
    for (int i = 0; i < N; i++) {
        vector<int> p;
        vector<bool> vis(N);
        auto dfs = [&](auto dfs, int x) -> int {
            p.push_back(x);
            vis[x] = 1;
            int f = 1;
            for (int y : adj[x]) {
                if (!vis[y]) {
                    if (dfs(dfs, y) == A[x]) {
                        f = 0;
                    }
                } else {
                    int cyc = 0;
                    for (int i = p.size() - 1; i >= 0; i--) {
                        cyc |= R[p[i]];
                        if (p[i] == y) {
                            break;
                        }
                    }
                    if (A[x] == cyc) {
                        f = 0;
                    }
                }
            }
            vis[x] = 0;
            p.pop_back();
            return A[x] ^ f;
        };
        ans[i] = dfs(dfs, i);
    }
    return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 344 ms 1364 KB Output is correct
2 Correct 127 ms 980 KB Output is correct
3 Correct 56 ms 852 KB Output is correct
4 Correct 22 ms 836 KB Output is correct
5 Correct 10 ms 808 KB Output is correct
6 Correct 6 ms 724 KB Output is correct
7 Correct 6 ms 724 KB Output is correct
8 Correct 5 ms 724 KB Output is correct
9 Correct 4 ms 724 KB Output is correct
10 Correct 4 ms 724 KB Output is correct
11 Correct 3 ms 724 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 298 ms 280 KB Output is correct
5 Correct 0 ms 304 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 6 ms 312 KB Output is correct
9 Correct 102 ms 284 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 41 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 304 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2064 ms 980 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2039 ms 1156 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2045 ms 1204 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 344 ms 1364 KB Output is correct
2 Correct 127 ms 980 KB Output is correct
3 Correct 56 ms 852 KB Output is correct
4 Correct 22 ms 836 KB Output is correct
5 Correct 10 ms 808 KB Output is correct
6 Correct 6 ms 724 KB Output is correct
7 Correct 6 ms 724 KB Output is correct
8 Correct 5 ms 724 KB Output is correct
9 Correct 4 ms 724 KB Output is correct
10 Correct 4 ms 724 KB Output is correct
11 Correct 3 ms 724 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 298 ms 280 KB Output is correct
16 Correct 0 ms 304 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 6 ms 312 KB Output is correct
20 Correct 102 ms 284 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 41 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 0 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 0 ms 212 KB Output is correct
28 Correct 0 ms 212 KB Output is correct
29 Correct 0 ms 304 KB Output is correct
30 Correct 0 ms 212 KB Output is correct
31 Correct 1 ms 212 KB Output is correct
32 Execution timed out 2064 ms 980 KB Time limit exceeded
33 Halted 0 ms 0 KB -