Submission #612571

# Submission time Handle Problem Language Result Execution time Memory
612571 2022-07-29T17:46:14 Z MohamedAliSaidane Toy Train (IOI17_train) C++14
5 / 100
2000 ms 1256 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 )
    {

        if(dep == 0)
            return 0;
        if(C[x] == 1)
            dep = n;
        vis[x] = 1;
        int ans = -1;
        for(auto e: adj[x])
        {
            int rep;
            if(vis[e])
                rep = e == x? C[x]: 1;
            else
                rep = dfs(e, dep - 1);
            if(ans == -1)
                ans = rep;
            else
            {
                if(A[x])
                    if(rep == 1)
                        ans = 1;

                if(!A[x])
                    if(rep == 0)
                        ans = 0;
            }
        }
        vis[x] = 0 ;
        return ans;
    }
    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 ++)
        {
            ans[i] = dfs(i, n);
        }
        return ans;
    }
# Verdict Execution time Memory Grader output
1 Correct 266 ms 1204 KB Output is correct
2 Correct 83 ms 1088 KB Output is correct
3 Correct 35 ms 1000 KB Output is correct
4 Correct 14 ms 956 KB Output is correct
5 Correct 7 ms 852 KB Output is correct
6 Correct 5 ms 912 KB Output is correct
7 Correct 5 ms 848 KB Output is correct
8 Correct 5 ms 820 KB Output is correct
9 Correct 4 ms 852 KB Output is correct
10 Correct 5 ms 844 KB Output is correct
11 Correct 5 ms 852 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Incorrect 1 ms 340 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2070 ms 1108 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2073 ms 1120 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2077 ms 1256 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 266 ms 1204 KB Output is correct
2 Correct 83 ms 1088 KB Output is correct
3 Correct 35 ms 1000 KB Output is correct
4 Correct 14 ms 956 KB Output is correct
5 Correct 7 ms 852 KB Output is correct
6 Correct 5 ms 912 KB Output is correct
7 Correct 5 ms 848 KB Output is correct
8 Correct 5 ms 820 KB Output is correct
9 Correct 4 ms 852 KB Output is correct
10 Correct 5 ms 844 KB Output is correct
11 Correct 5 ms 852 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Incorrect 1 ms 340 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
14 Halted 0 ms 0 KB -