답안 #884384

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
884384 2023-12-07T09:17:14 Z abcvuitunggio 장난감 기차 (IOI17_train) C++17
0 / 100
7 ms 1884 KB
#include "train.h"
#include <bits/stdc++.h>
using namespace std;
vector <int> ke[5001],ke2[5001],ke3[5001],d;
int n,m,vis[5001],p[5001],sz[5001],ch[5001];
stack <int> st;
queue <int> q;
void dfs(int u){
    vis[u]=1;
    for (int v:ke[u])
        if (!vis[v])
            dfs(v);
    st.push(u);
}
void dfs2(int u){
    sz[p[u]]++;
    vis[u]=1;
    for (int v:ke2[u])
        if (!vis[v]){
            p[v]=p[u];
            dfs2(v);
        }
}
vector <int> who_wins(vector <int> a, vector <int> r, vector <int> u, vector <int> v){
    n=a.size(),m=u.size();
    for (int i=0;i<m;i++){
        if (u[i]==v[i])
            ch[u[i]]=1;
        ke3[v[i]].push_back(u[i]);
        if (r[u[i]]||r[v[i]])
            continue;
        ke[u[i]].push_back(v[i]);
        ke2[v[i]].push_back(u[i]);
    }
    for (int i=0;i<n;i++)
        if (!vis[i])
            dfs(i);
    iota(p,p+n,0);
    memset(vis,0,sizeof(vis));
    while (!st.empty()){
        int u=st.top();
        st.pop();
        if (!vis[u])
            dfs2(u);
    }
    d.assign(n,0);
    for (int i=0;i<n;i++){
        if (!r[i]&&(sz[p[i]]>1||ch[i])){
            d[i]=1;
            q.push(i);
        }
    }
    while (!q.empty()){
        int u=q.front();
        q.pop();
        for (int v:ke3[u])
            if (!d[v]){
                d[v]=1;
                q.push(v);
            }
    }
    return d;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 1368 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 600 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 1884 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 1372 KB 3rd lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 7 ms 1880 KB 3rd lines differ - on the 2nd token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 1368 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -