답안 #406831

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
406831 2021-05-18T05:48:10 Z daniel920712 장난감 기차 (IOI17_train) C++14
0 / 100
1167 ms 25528 KB
#include "train.h"
#include <stdio.h>

using namespace std;
vector < int > Next[5005],Next2[5005],ans,P,W;
bool have1[5005][5005];
bool can[5005];
bool have2[5][5005];
bool vis[5005];
bool F(int st,int here,int deg)
{

    int ok=0,t;
    vis[here]=1;
    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) ok=1;
    }
    if(ok) can[here]=W[here];
    else can[here]=1-W[here];
    return can[here];

}
void F2(int here,int xx)
{
    if(have2[xx][here]) return;
    have2[xx][here]=1;
    for(auto i:Next2[here]) F2(i,xx);
}
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(vis[i]) F2(i,can[i]);

    for(i=0;i<N;i++)
    {
        if(have2[0][i]&&have2[1][i]) ans[i]=who[i];
        else if(have2[0][i]) ans[i]=0;
        else ans[i]=1;
    }
	return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 170 ms 15676 KB 3rd lines differ - on the 3rd token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 460 KB 3rd lines differ - on the 2nd token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 22 ms 5840 KB Output is correct
2 Correct 44 ms 9540 KB Output is correct
3 Correct 84 ms 13232 KB Output is correct
4 Correct 434 ms 12000 KB Output is correct
5 Correct 64 ms 4424 KB Output is correct
6 Correct 112 ms 5188 KB Output is correct
7 Correct 330 ms 18732 KB Output is correct
8 Correct 9 ms 1612 KB Output is correct
9 Correct 9 ms 1612 KB Output is correct
10 Correct 12 ms 1868 KB Output is correct
11 Incorrect 9 ms 1612 KB 3rd lines differ - on the 204th token, expected: '0', found: '1'
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1167 ms 25528 KB 3rd lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 10 ms 1484 KB 3rd lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 170 ms 15676 KB 3rd lines differ - on the 3rd token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -