Submission #612613

# Submission time Handle Problem Language Result Execution time Memory
612613 2022-07-29T18:17:47 Z MohamedAliSaidane Toy Train (IOI17_train) C++14
12 / 100
2000 ms 1832 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], rev_adj[nax];
    int cnt[nax], sz[nax];
    vi who_wins(vi a, vi r, vi u, vi v)
    {
        set<int> cur;
        n = a.size();
        m = u.size();

        for(int i=  0; i < m; i ++)
        {
            adj[u[i]].pb(v[i]);
            rev_adj[v[i]].pb(u[i]);
        }
        for(int i = 0 ; i < n; i ++ )
            sz[i] = (int)(adj[i].size());

        vi ans(n, 0);
        for(int org = 0; org < n; org ++)
        {
            if(!r[org])
                continue;
            set<int> cur;
            cur.insert(org);
            for(auto o: rev_adj[org])
                cnt[o]++;
            for(int i = 0 ; i < n; i++)
            {
                set<int> nw;
                for(int j=  0; j < n; j ++)
                {
                    if(cur.count(j) !=0 || nw.count(j) != 0)
                        continue;
                    if(a[j])
                    {
                        if(cnt[j] > 0)
                            nw.insert(j);
                    }
                    else
                    {
                        if(cnt[j] == sz[j])
                            nw.insert(j);
                    }
                }
                for(auto e: nw)
                {
                    for(auto o: rev_adj[e])
                        cnt[o] ++ ;
                    cur.insert(e);
                }
            }
            if(a[org])
            {
                if(cnt[org] > 0 )
                {
                    for(auto e: cur)
                        ans[e] = 1;
                }
            }
            else
            {
                if(cnt[org] == sz[org])
                    for(auto e: cur)
                        ans[e] = 1;
            }
        }

        return ans;

    }
# Verdict Execution time Memory Grader output
1 Execution timed out 2071 ms 980 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 468 KB 3rd lines differ - on the 4th token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2079 ms 1808 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2075 ms 1220 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1014 ms 1500 KB Output is correct
2 Correct 1128 ms 1832 KB Output is correct
3 Correct 1112 ms 1772 KB Output is correct
4 Correct 1133 ms 1620 KB Output is correct
5 Correct 1 ms 596 KB Output is correct
6 Correct 207 ms 1108 KB Output is correct
7 Correct 9 ms 1196 KB Output is correct
8 Correct 9 ms 1236 KB Output is correct
9 Correct 10 ms 1276 KB Output is correct
10 Correct 2 ms 724 KB Output is correct
11 Correct 19 ms 1192 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 2071 ms 980 KB Time limit exceeded
2 Halted 0 ms 0 KB -