Submission #290917

# Submission time Handle Problem Language Result Execution time Memory
290917 2020-09-04T14:39:47 Z Kastanda Toy Train (IOI17_train) C++11
11 / 100
1379 ms 1656 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]);
        }


        for (int __ = 0; __ < n; __ ++)
        {
                queue < int > qu;
                memset(D, 0, sizeof(D));
                memset(Z, 0, sizeof(Z));
                for (int i = 0; i < n; i ++)
                        if ((__ == 0 && R[i]) || (__ > 0 && !F[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 551 ms 1272 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 550 ms 1656 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 606 ms 1400 KB Output is correct
2 Correct 992 ms 1548 KB Output is correct
3 Correct 682 ms 1528 KB Output is correct
4 Correct 632 ms 1532 KB Output is correct
5 Correct 1053 ms 1528 KB Output is correct
6 Correct 992 ms 1512 KB Output is correct
7 Correct 1153 ms 1528 KB Output is correct
8 Correct 653 ms 1408 KB Output is correct
9 Correct 1050 ms 1444 KB Output is correct
10 Correct 632 ms 1528 KB Output is correct
11 Correct 627 ms 1528 KB Output is correct
12 Correct 616 ms 1512 KB Output is correct
13 Correct 1163 ms 1512 KB Output is correct
14 Correct 1113 ms 1408 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1379 ms 1528 KB Output is correct
2 Correct 618 ms 1528 KB Output is correct
3 Correct 1220 ms 1528 KB Output is correct
4 Correct 628 ms 1504 KB Output is correct
5 Correct 2 ms 640 KB Output is correct
6 Correct 473 ms 1272 KB Output is correct
7 Correct 51 ms 1152 KB Output is correct
8 Incorrect 65 ms 1272 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 551 ms 1272 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -