Submission #406816

# Submission time Handle Problem Language Result Execution time Memory
406816 2021-05-18T05:34:16 Z daniel920712 Toy Train (IOI17_train) C++14
0 / 100
1029 ms 25488 KB
#include "train.h"
using namespace std;
vector < int > Next[5005],Next2[5005],ans,P,W;
bool have1[5005][5005];
bool can[5005];
bool have2[5005];
bool F(int st,int here,int deg)
{
    int t=1-W[here];
    if(here==st&&deg) return 1;
    if(have1[st][here]) return can[here];
    have1[st][here]=1;
    for(auto i:Next[here])
    {
        t=F(st,i,deg+1);
        if(W[here]==t) t=1-t;
    }
    can[here]=t;
    return t;

}
void F2(int here)
{
    if(have2[here]) return;
    have2[here]=1;
    for(auto i:Next2[here]) F2(i);
}
vector < int > who_wins(vector < int > who, vector < int > power, vector < int > u, vector < int > v)
{
    P=power;
    W=who;
    int N=who.size(),M=u.size(),i;
	for(i=0;i<N;i++) ans.push_back(0);
	for(i=0;i<M;i++) Next[u[i]].push_back(v[i]);
	for(i=0;i<M;i++) Next2[v[i]].push_back(u[i]);
    for(i=0;i<N;i++) if(power[i]) F(i,i,0);
    for(i=0;i<N;i++) if(can[i]) F2(i);

    for(i=0;i<N;i++) ans[i]=have2[i];
	return ans;
}
# Verdict Execution time Memory Grader output
1 Incorrect 165 ms 15428 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 460 KB 3rd lines differ - on the 8th token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 17 ms 5836 KB Output is correct
2 Correct 43 ms 9872 KB Output is correct
3 Correct 79 ms 13424 KB Output is correct
4 Incorrect 440 ms 12264 KB 3rd lines differ - on the 1st token, expected: '1', found: '0'
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1029 ms 25488 KB 3rd lines differ - on the 696th token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 1564 KB 3rd lines differ - on the 2nd token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 165 ms 15428 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -