Submission #290913

# Submission time Handle Problem Language Result Execution time Memory
290913 2020-09-04T14:34:29 Z Kastanda Toy Train (IOI17_train) C++11
11 / 100
11 ms 1792 KB
// M
#include<bits/stdc++.h>
#include "train.h"
using namespace std;
const int N = 5005;
int n, m, A[N], R[N], Z[N], F[N], D[N];
vector < int > in[N], out[N];

vector < int > who_wins(vector < int > _A, vector < int > _R, vector < int > _U, vector < int > _V)
{
        n = (int)_A.size();
        m = (int)_U.size();
        for (int i = 0; i < n; i ++)
                A[i] = _A[i];
        for (int i = 0; i < n; i ++)
                R[i] = _R[i];
        for (int i = 0; i < m; i ++)
        {
                out[_U[i]].push_back(_V[i]);
                in[_V[i]].push_back(_U[i]);
        }


        queue < int > qu;
        for (int i = 0; i < n; i ++)
                if (R[i])
                        Z[i] = 1, qu.push(i);
        while (qu.size())
        {
                int v = qu.front();
                qu.pop();
                for (int u : in[v])
                        if (!Z[u])
                        {
                                if (A[u])
                                        Z[u] = 1, qu.push(u);
                                else
                                {
                                        D[u] ++;
                                        if (D[u] == (int)out[u].size())
                                                Z[u] = 1, qu.push(u);
                                }
                        }
        }

        memset(D, 0, sizeof(D));
        for (int i = 0; i < n; i ++)
                if (!Z[i])
                        F[i] = 1, qu.push(i);
        while (qu.size())
        {
                int v = qu.front();
                qu.pop();
                for (int u : in[v])
                        if (!F[u])
                        {
                                if (!A[u])
                                        F[u] = 1, qu.push(u);
                                else
                                {
                                        D[u] ++;
                                        if (D[u] == (int)out[u].size())
                                                F[u] = 1, qu.push(u);
                                }
                        }
        }

        vector < int > Rs;
        for (int i = 0; i < n; i ++)
                Rs.push_back(F[i] == 0);
        return Rs;

}
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 1152 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 Correct 1 ms 640 KB Output is correct
2 Correct 1 ms 640 KB Output is correct
3 Correct 1 ms 640 KB Output is correct
4 Incorrect 1 ms 640 KB 3rd lines differ - on the 4th token, expected: '0', found: '1'
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 10 ms 1664 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 Correct 9 ms 1408 KB Output is correct
2 Correct 9 ms 1664 KB Output is correct
3 Correct 11 ms 1768 KB Output is correct
4 Correct 11 ms 1792 KB Output is correct
5 Correct 10 ms 1792 KB Output is correct
6 Correct 10 ms 1664 KB Output is correct
7 Correct 11 ms 1664 KB Output is correct
8 Correct 10 ms 1664 KB Output is correct
9 Correct 10 ms 1664 KB Output is correct
10 Correct 11 ms 1792 KB Output is correct
11 Correct 11 ms 1792 KB Output is correct
12 Correct 11 ms 1792 KB Output is correct
13 Correct 11 ms 1792 KB Output is correct
14 Correct 10 ms 1664 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 1536 KB Output is correct
2 Correct 11 ms 1664 KB Output is correct
3 Correct 11 ms 1792 KB Output is correct
4 Correct 10 ms 1664 KB Output is correct
5 Correct 2 ms 640 KB Output is correct
6 Correct 5 ms 1280 KB Output is correct
7 Correct 7 ms 1280 KB Output is correct
8 Incorrect 7 ms 1280 KB 3rd lines differ - on the 5th token, expected: '0', found: '1'
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 1152 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -