Submission #33249

# Submission time Handle Problem Language Result Execution time Memory
33249 2017-10-23T04:36:47 Z model_code Toy Train (IOI17_train) C++11
12 / 100
13 ms 3148 KB
#include "train.h"

#include <iostream>
#include <vector>
#include <queue>

using namespace std;

const int MAXN = 5000+10;

const int B = 0;
const int A = 1;

int need[MAXN]; 
vector<int> adj[MAXN], bak[MAXN];

vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u, vector<int> v){
    for (int i = 0; i < (int)u.size(); i++) {
        adj[u[i]].push_back(v[i]);
        bak[v[i]].push_back(u[i]);
    }
    int n = (int)a.size();
    for (int i = 0; i < n; i++) {
        if (a[i] == A)
            need[i] = 1;
        else
            need[i] = adj[i].size();
    }
    int who = 0;
    for (int i = 0; i < n; i++) if (r[i] == 1)
        who = i;
    vector<int> res(n, B);
    res[who] = A;
    queue<int> q;
    q.push(who);
    while (!q.empty()) {
        int front = q.front(); q.pop();
        for (int i = 0; i < (int)bak[front].size(); i++) {
            int temp = bak[front][i];
            --need[temp];
            if (need[temp] == 0 && res[temp] == B) {
                q.push(temp);
                res[temp] = A;
            }
        }
    }
    if (need[who] > 0)
        res = vector<int>(n, B);
    return res;
}
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 2808 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 2272 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 6 ms 3148 KB Output is correct
2 Correct 3 ms 3148 KB Output is correct
3 Correct 3 ms 3148 KB Output is correct
4 Correct 9 ms 3148 KB Output is correct
5 Correct 9 ms 3148 KB Output is correct
6 Incorrect 9 ms 3148 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 6 ms 3016 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 9 ms 3148 KB Output is correct
2 Correct 13 ms 3148 KB Output is correct
3 Correct 9 ms 3148 KB Output is correct
4 Correct 6 ms 2988 KB Output is correct
5 Correct 0 ms 2404 KB Output is correct
6 Correct 0 ms 2820 KB Output is correct
7 Correct 3 ms 2824 KB Output is correct
8 Correct 3 ms 2848 KB Output is correct
9 Correct 6 ms 2840 KB Output is correct
10 Correct 0 ms 2412 KB Output is correct
11 Correct 6 ms 2876 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 2808 KB 3rd lines differ - on the 14th token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -