Submission #583899

# Submission time Handle Problem Language Result Execution time Memory
583899 2022-06-26T12:50:31 Z PiejanVDC Toy Train (IOI17_train) C++17
0 / 100
9 ms 1256 KB
#include <bits/stdc++.h>
#include "train.h"

using namespace std;

vector<int>who_wins(vector<int>a, vector<int>r, vector<int>u, vector<int>v) {

    int n = r.size();
    int m = u.size();

    vector<int>adj[n];

    vector<int>cnt(n,0);

    for(int i = 0 ; i < m ; i++)
        adj[v[i]].push_back(u[i]), cnt[u[i]]++;

    stack<int>s;

    for(int i = 0 ; i < n ; i++) {
        if(r[i])
            s.push(i);
    }

    vector<int>ans(n,0);

    while(!s.empty()) {

        int node = s.top();
        s.pop();

        ans[node] = 1;

        for(auto z : adj[node]) if(!ans[z]) {
            cnt[z]--;
            if(a[z] || !cnt[z]) {
                s.push(z);
            }
        }
    }

    return ans;
}
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 852 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 300 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 1216 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 1108 KB 3rd lines differ - on the 696th token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 1256 KB 3rd lines differ - on the 545th token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 852 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -