Submission #733185

# Submission time Handle Problem Language Result Execution time Memory
733185 2023-04-30T08:06:59 Z t6twotwo Toy Train (IOI17_train) C++17
0 / 100
2000 ms 1140 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> pos(N, -1), c{-1};
        int t = 0;
        auto dfs = [&](auto dfs, int x) -> int {
            pos[x] = t++;
            if (R[x]) {
                c.push_back(pos[x]);
            }
            for (int y : adj[x]) {
                if (pos[y] == -1) {
                    if (dfs(dfs, y) == A[x]) {
                        return A[x];
                    }
                } else {
                    if (A[x] == (pos[y] <= c.back())) {
                        return A[x];
                    }
                }
            }
            pos[x] = -1; t--;
            if (R[x]) {
                c.pop_back();
            }
            return !A[x];
        };
        ans[i] = dfs(dfs, i);
    }
    return ans;
}
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 724 KB 3rd lines differ - on the 141st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB 3rd lines differ - on the 2nd token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2029 ms 980 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2073 ms 1140 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 823 ms 1108 KB 3rd lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 724 KB 3rd lines differ - on the 141st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -