Submission #612419

# Submission time Handle Problem Language Result Execution time Memory
612419 2022-07-29T14:35:12 Z MohamedAliSaidane Toy Train (IOI17_train) C++14
0 / 100
408 ms 262144 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;
    int C[nax];
    vi adj[nax];
    vi rev_adj[nax];
    int A[nax];
    int n, m;
    int dp[nax][nax];
    int f(int x, int rem)
    {
        if(dp[x][rem] != -1)
            return dp[x][rem];
        int nw_rem = rem;
        if(rem == 0)
            return dp[x][rem] = 1 - A[x];
        if(C[x])
            nw_rem = n;
        int rep  = 0;
        for(auto e: adj[x])
        {
            if(e == x)
            {
                if(C[x])
                    rep = rep | A[x];
            }
            else
                rep = rep | f(e, nw_rem - 1);
        }
        return dp[x][rem] = rep;
    }
    vi who_wins(vi a, vi r, vi u, vi v)
    {
        memset(dp, -1,sizeof(dp));
        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;
        for(int i = 0; i < n;i ++)
        {
            if(f(i, n))
                ans.pb(A[i]);
            else
                ans.pb(1 - A[i]);
        }
        return ans;
    }
# Verdict Execution time Memory Grader output
1 Incorrect 39 ms 99276 KB 3rd lines differ - on the 3rd token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 114 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 408 ms 99932 KB Output is correct
2 Correct 270 ms 99776 KB Output is correct
3 Correct 285 ms 99760 KB Output is correct
4 Runtime error 120 ms 262144 KB Execution killed with signal 9
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 115 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 116 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 39 ms 99276 KB 3rd lines differ - on the 3rd token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -