Submission #1033617

# Submission time Handle Problem Language Result Execution time Memory
1033617 2024-07-25T04:06:19 Z vjudge1 Toy Train (IOI17_train) C++17
0 / 100
10 ms 8220 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;
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]=1;
    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();
    ans.resize(n,0);
    for(int i=0;i<u.size();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(sz[cmp[i]]>1&&r[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:35:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |     for(int i=0;i<u.size();i++)
      |                 ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 7772 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 1 ms 6748 KB 3rd lines differ - on the 8th token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 8220 KB Output is correct
2 Correct 5 ms 8216 KB Output is correct
3 Correct 8 ms 8028 KB Output is correct
4 Correct 7 ms 8028 KB Output is correct
5 Correct 7 ms 8028 KB Output is correct
6 Correct 8 ms 8028 KB Output is correct
7 Correct 8 ms 7992 KB Output is correct
8 Correct 10 ms 8028 KB Output is correct
9 Correct 6 ms 7772 KB Output is correct
10 Correct 6 ms 7968 KB Output is correct
11 Incorrect 7 ms 7772 KB 3rd lines differ - on the 89th token, expected: '1', found: '0'
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 7772 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 8028 KB 3rd lines differ - on the 2nd token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 7772 KB 3rd lines differ - on the 14th token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -