Submission #612484

# Submission time Handle Problem Language Result Execution time Memory
612484 2022-07-29T15:49:23 Z MohamedAliSaidane Toy Train (IOI17_train) C++14
0 / 100
2000 ms 1584 KB
#include <bits/stdc++.h>
//#include "train.h"
    using namespace std;

    typedef long long ll;
    typedef double ld;
    typedef pair<int,int> pii;
    typedef pair<ll,ll> pll;

    typedef vector<int> vi;
    typedef vector<ll> vll;
    typedef vector<pii> vpi;
    typedef vector<pll> vpl;

    #define pb push_back
    #define popb pop_back
    #define all(x) (x).begin(),(x).end()

    #define ff first
    #define ss second

    const int nax = 5004;
    const int MOD = 1e9 + 7;
    int  n, m;
    vi adj[nax];
    int vis[nax];
    int A[nax], C[nax];
    int dfs(int x, int dep = n)
    {
        vis[x] = 1;
        dep = C[x] ? n: dep;
        if(dep == 0)
            return 1 - A[x];
        int rep = 0;
        for(auto e: adj[x])
        {
            if(vis[e])
            {
                if(A[x])
                    rep = 1;
            }
            else
            {
                if(A[e] == A[x])
                {
                    if(rep == 0 )
                        rep = dfs(e, dep - 1);
                }
                else
                {
                    if(rep == 0)
                        rep = 1 - dfs(e, dep - 1);
                }
            }
        }
        vis[x] = 0;
        return rep;
    }
    vi who_wins(vi a, vi r, vi u, vi v)
    {
        n = a.size();
        m = u.size();
        for(int i = 0 ; i < n; i++)
        {
            A[i] = a[i];
            C[i ] = r[i];
        }
        for(int i = 0 ; i  < m; i ++)
        {
            adj[u[i]].pb(v[i]);
        }
        vi ans(n, 0);
        for(int i = 0 ; i < n; i ++)
        {
            int rep  = dfs(i, n);
            if(A[i])
                ans[i] = rep;
            else
                ans[i] = 1 - rep;
        }
        return ans;

    }
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 852 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 Incorrect 1 ms 340 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 Incorrect 153 ms 1584 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 Execution timed out 2076 ms 1236 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2070 ms 1364 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 852 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -