Submission #425766

# Submission time Handle Problem Language Result Execution time Memory
425766 2021-06-13T11:12:02 Z MOUF_MAHMALAT Toy Train (IOI17_train) C++14
10 / 100
2000 ms 1176 KB
#include "train.h"
#include<bits/stdc++.h>
using namespace std;
typedef int ll;
vector<vector<ll> >v;
ll n,id[5009];
bool b[5009],c[5009];
bool best(ll d,ll op)
{
    if(c[d])
        op=n;
    if(op==0)
        return 0;
    if(id[d]!=-1)
    {
        if(c[d])
            return 1;
        return best(id[d],op-1);
    }
    bool r=b[d]^1;
    for(auto z:v[d])
    {
        id[d]=z;
        if(b[d])
            r|=best(id[d],op-1);
        else
            r&=best(id[d],op-1);
        id[d]=-1;
    }
    return r;
}
vector<int> who_wins(vector<int> A, vector<int> R, vector<int> from, vector<int> to)
{
    n=A.size();
    v.resize(n);
    for(ll i=0; i<to.size(); i++)
        v[from[i]].push_back(to[i]);
    for(ll i=0; i<n; i++)
        b[i]=A[i],c[i]=R[i];
    vector<ll>ans;
    memset(id,-1,sizeof id);
    for(ll i=0; i<n; i++)
        ans.push_back(best(i,n));
    return ans;
}

Compilation message

train.cpp: In function 'std::vector<int> who_wins(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
train.cpp:36:18: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |     for(ll i=0; i<to.size(); i++)
      |                 ~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Execution timed out 2041 ms 1064 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 228 ms 308 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 300 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 7 ms 204 KB Output is correct
9 Correct 85 ms 204 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 49 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 300 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 2070 ms 972 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2071 ms 1036 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2028 ms 1176 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2041 ms 1064 KB Time limit exceeded
2 Halted 0 ms 0 KB -