Submission #884377

# Submission time Handle Problem Language Result Execution time Memory
884377 2023-12-07T09:06:18 Z abcvuitunggio Toy Train (IOI17_train) C++17
0 / 100
7 ms 1628 KB
#include "train.h"
#include <bits/stdc++.h>
using namespace std;
vector <int> ke[5001],ke2[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[u])
            dfs(v);
    st.push(u);
}
void dfs2(int u){
    sz[p[u]]++;
    vis[u]=1;
    for (int v:ke2[u])
        if (!vis[u]){
            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;
        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:ke2[u])
            if (!d[v]){
                d[v]=1;
                q.push(v);
            }
    }
    return d;
}
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 1116 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 0 ms 604 KB 3rd lines differ - on the 2nd token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 1624 KB Output is correct
2 Correct 5 ms 1628 KB Output is correct
3 Correct 5 ms 1624 KB Output is correct
4 Incorrect 6 ms 1372 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 5 ms 1372 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 7 ms 1372 KB 3rd lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 1116 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -