Submission #1054769

# Submission time Handle Problem Language Result Execution time Memory
1054769 2024-08-12T12:03:01 Z Wansur Toy Train (IOI17_train) C++14
12 / 100
8 ms 1756 KB
#include <bits/stdc++.h>
#include "train.h"
#define ent '\n'
#define  f first
#define s second
//#define int long long

using namespace std;
typedef long long ll;
const int maxn = 5e3 + 12;
const int mod = 1e9 + 7;

vector<int> g[maxn], rg[maxn];
int in[maxn], out[maxn];
bool won[maxn];
int n, m;

vector<int> who_wins(vector<int> a, vector<int> r, vector<int> U, vector<int> V){
    n = a.size(), m = U.size();
    int v = -1;
    
    for(int i=0;i<n;i++){
        if(r[i]){
            v = i;
        }
    }
    won[v] = 1;
    for(int i=0;i<m;i++){
        g[U[i]].push_back(V[i]);
        rg[V[i]].push_back(U[i]);
        out[U[i]]++, in[V[i]]++;
    }
    queue<int> q;
    q.push(v);
    while(q.size()){
        int v = q.front();
        q.pop();
        for(int to:rg[v]){
            if(a[to] == 1 && !won[to]){
                won[to] = 1;
                q.push(to);
            }
            else if(a[to] == 0){
                out[to]--;
                if(!out[to]){
                    won[to] = 1;
                    q.push(to);
                }
            }
        }
    }

    bool ok = 0;

    for(int to:g[v]){
        if(won[to]){
            ok = 1;
        }
    }
    vector<int> ans(n);
    if(ok){
        for(int i=0;i<n;i++){
            ans[i] = won[i];
        }
    }
    return ans;
}
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 1116 KB 3rd lines differ - on the 14th token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 604 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 Correct 3 ms 1372 KB Output is correct
2 Correct 3 ms 1592 KB Output is correct
3 Correct 4 ms 1628 KB Output is correct
4 Correct 4 ms 1756 KB Output is correct
5 Correct 4 ms 1628 KB Output is correct
6 Incorrect 4 ms 1600 KB 3rd lines differ - on the 47th token, expected: '1', found: '0'
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 1368 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 Correct 8 ms 1372 KB Output is correct
2 Correct 4 ms 1372 KB Output is correct
3 Correct 4 ms 1380 KB Output is correct
4 Correct 4 ms 1372 KB Output is correct
5 Correct 0 ms 604 KB Output is correct
6 Correct 2 ms 1116 KB Output is correct
7 Correct 2 ms 1116 KB Output is correct
8 Correct 2 ms 1116 KB Output is correct
9 Correct 3 ms 1116 KB Output is correct
10 Correct 1 ms 860 KB Output is correct
11 Correct 2 ms 1116 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 1116 KB 3rd lines differ - on the 14th token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -