Submission #406726

# Submission time Handle Problem Language Result Execution time Memory
406726 2021-05-18T03:49:07 Z daniel920712 Toy Train (IOI17_train) C++14
11 / 100
454 ms 25524 KB
#include "train.h"
using namespace std;
vector < int > Next[5005],Next2[5005],ans;
bool have1[5005][5005];
bool can[5005];
bool have2[5005];
bool F(int st,int here,int deg)
{
    int t=0;
    if(here==st&&deg) return 1;
    if(have1[st][here]) return 0;
    have1[st][here]=1;
    for(auto i:Next[here])
    {
        t=F(st,i,deg+1);
        can[here]=can[here]||t;
        if(t) break;
    }
    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)
{
    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++) if(have2[i]) ans[i]=1;
	return ans;
}
# Verdict Execution time Memory Grader output
1 Incorrect 109 ms 14804 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 16 ms 5908 KB Output is correct
2 Correct 36 ms 9676 KB Output is correct
3 Correct 84 ms 13252 KB Output is correct
4 Correct 153 ms 11984 KB Output is correct
5 Correct 48 ms 4628 KB Output is correct
6 Correct 117 ms 5320 KB Output is correct
7 Correct 251 ms 18464 KB Output is correct
8 Correct 9 ms 1612 KB Output is correct
9 Correct 9 ms 1560 KB Output is correct
10 Correct 15 ms 1804 KB Output is correct
11 Correct 11 ms 1484 KB Output is correct
12 Correct 8 ms 1484 KB Output is correct
13 Correct 13 ms 1740 KB Output is correct
14 Correct 10 ms 1740 KB Output is correct
15 Correct 13 ms 1740 KB Output is correct
16 Correct 9 ms 1604 KB Output is correct
17 Correct 12 ms 1612 KB Output is correct
18 Correct 207 ms 18752 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 454 ms 25524 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 10 ms 1484 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 109 ms 14804 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -