Submission #1033686

# Submission time Handle Problem Language Result Execution time Memory
1033686 2024-07-25T04:15:19 Z vjudge1 Toy Train (IOI17_train) C++17
11 / 100
7 ms 6272 KB
#include "train.h"
#include<bits/stdc++.h>
using namespace std;
vector<int>adj[100100],radj[100100];
stack<int>stk;
int onstk[100100],id[100100],low[100100],cmp[100100],sz[100100],CC,slf[100100];
void tarjan(int n){
    onstk[n]=1;
    stk.push(n);
    id[n]=low[n]=++CC;
    for(auto i:adj[n]){
        if(!id[i])
            tarjan(i);
        if(onstk[i])
            low[n]=min(low[n],low[i]);
    }
    if(low[n]==id[n]){
        while(onstk[n]){
            int x=stk.top();
            stk.pop();cmp[x]=n;
            onstk[x]=0,sz[n]++;
        }
    }
}
vector<int>ans;
void yes(int n){
    if(!ans[n])return;
    ans[n]=0;
    for(auto x:radj[n])
        yes(x);
}
std::vector<int> who_wins(std::vector<int> a, std::vector<int> r, std::vector<int> u, std::vector<int> v) {
    int n=a.size(),m=u.size();
    ans.resize(n,1);
    for(int i=0;i<m;i++){
        if(!r[u[i]]&&!r[v[i]])
            slf[u[i]]|=v[i]==u[i],
            adj[u[i]].push_back(v[i]);
        radj[v[i]].push_back(u[i]);
    }
    for(int i=0;i<n;i++)
        if(!id[i])tarjan(i);
    for(int i=0;i<n;i++)
        if(!r[i]&&sz[cmp[i]]>1||slf[i])
            yes(i);
    return ans;
}

Compilation message

train.cpp: In function 'std::vector<int> who_wins(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
train.cpp:44:17: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   44 |         if(!r[i]&&sz[cmp[i]]>1||slf[i])
      |            ~~~~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 5720 KB 3rd lines differ - on the 14th token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 4956 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 6 ms 6236 KB Output is correct
2 Correct 6 ms 5980 KB Output is correct
3 Correct 5 ms 5980 KB Output is correct
4 Incorrect 6 ms 5980 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 Correct 5 ms 5720 KB Output is correct
2 Correct 6 ms 5980 KB Output is correct
3 Correct 7 ms 6060 KB Output is correct
4 Correct 5 ms 5980 KB Output is correct
5 Correct 6 ms 6236 KB Output is correct
6 Correct 5 ms 6236 KB Output is correct
7 Correct 5 ms 6236 KB Output is correct
8 Correct 6 ms 5980 KB Output is correct
9 Correct 4 ms 5980 KB Output is correct
10 Correct 5 ms 5980 KB Output is correct
11 Correct 6 ms 5976 KB Output is correct
12 Correct 5 ms 5980 KB Output is correct
13 Correct 6 ms 6236 KB Output is correct
14 Correct 6 ms 6272 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 6236 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 4 ms 5720 KB 3rd lines differ - on the 14th token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -