답안 #826236

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
826236 2023-08-15T11:25:24 Z vnm06 장난감 기차 (IOI17_train) C++14
11 / 100
566 ms 1748 KB
#include<bits/stdc++.h>
#include "train.h"

using namespace std;

int n, m;
bool isC[5005], used[5005];
vector<int> gr[5005], rev_gr[5005];

void dfs(int v)
{
    int brs=gr[v].size();
    for(int i=0; i<brs; i++)
    {
        int nv=gr[v][i];
        if(used[nv]) continue;
        used[nv]=1;
        dfs(nv);
    }
}

vector<int> ans;

void dfs2(int v)
{
    ans[v-1]=1;
    int brs=rev_gr[v].size();
    for(int i=0; i<brs; i++)
    {
        int nv=rev_gr[v][i];
        if(ans[nv-1]) continue;
        dfs2(nv);
    }
}

std::vector<int> who_wins(std::vector<int> a, std::vector<int> r, std::vector<int> u, std::vector<int> v)
{
    n=a.size();
    ans.resize(n);
    for(int i=0; i<n; i++) ans[i]=0;
    m=u.size();
    for(int i=0; i<n; i++) if(r[i]) isC[i+1]=1;
    for(int i=0; i<m; i++)
    {
        gr[u[i]+1].push_back(v[i]+1);
        rev_gr[v[i]+1].push_back(u[i]+1);
    }
    for(int i=1; i<=n; i++)
    {
        if(isC[i])
        {
            dfs(i);
            if(!used[i]) isC[i]=0;
            memset(used, 0, sizeof(used));
        }
    }
    for(int i=1; i<=n; i++)
    {
        if(isC[i]) dfs2(i);
    }
    return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 87 ms 1272 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 468 KB 3rd lines differ - on the 8th token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 1492 KB Output is correct
2 Correct 17 ms 1716 KB Output is correct
3 Correct 33 ms 1740 KB Output is correct
4 Correct 200 ms 1716 KB Output is correct
5 Correct 36 ms 1664 KB Output is correct
6 Correct 51 ms 1588 KB Output is correct
7 Correct 155 ms 1572 KB Output is correct
8 Correct 6 ms 1620 KB Output is correct
9 Correct 5 ms 1552 KB Output is correct
10 Correct 11 ms 1544 KB Output is correct
11 Correct 5 ms 1492 KB Output is correct
12 Correct 5 ms 1448 KB Output is correct
13 Correct 9 ms 1712 KB Output is correct
14 Correct 10 ms 1708 KB Output is correct
15 Correct 6 ms 1748 KB Output is correct
16 Correct 10 ms 1748 KB Output is correct
17 Correct 6 ms 1684 KB Output is correct
18 Correct 88 ms 1380 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 566 ms 1292 KB 3rd lines differ - on the 696th token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 1492 KB 3rd lines differ - on the 2nd token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 87 ms 1272 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -