Submission #290918

# Submission time Handle Problem Language Result Execution time Memory
290918 2020-09-04T14:43:20 Z Kastanda Toy Train (IOI17_train) C++11
11 / 100
14 ms 1536 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;; __ ++)
        {
                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] && !F[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));
                bool yodeloohoo = 0;
                for (int i = 0; i < n; i ++)
                        if (!Z[i] && !F[i])
                                F[i] = 1, yodeloohoo = 1;
                if (!yodeloohoo)
                        break;
                for (int i = 0; i < n; i ++)
                        if (F[i]) 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 9 ms 1536 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 10 ms 1408 KB Output is correct
3 Correct 12 ms 1536 KB Output is correct
4 Correct 10 ms 1536 KB Output is correct
5 Correct 10 ms 1536 KB Output is correct
6 Correct 10 ms 1536 KB Output is correct
7 Correct 10 ms 1536 KB Output is correct
8 Correct 10 ms 1408 KB Output is correct
9 Correct 10 ms 1480 KB Output is correct
10 Correct 11 ms 1536 KB Output is correct
11 Correct 10 ms 1536 KB Output is correct
12 Correct 11 ms 1536 KB Output is correct
13 Correct 11 ms 1536 KB Output is correct
14 Correct 10 ms 1408 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 1536 KB Output is correct
2 Correct 11 ms 1536 KB Output is correct
3 Correct 14 ms 1536 KB Output is correct
4 Correct 10 ms 1408 KB Output is correct
5 Correct 1 ms 640 KB Output is correct
6 Correct 5 ms 1152 KB Output is correct
7 Correct 7 ms 1152 KB Output is correct
8 Incorrect 7 ms 1152 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 -