답안 #1033667

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1033667 2024-07-25T04:12:12 Z vjudge1 장난감 기차 (IOI17_train) C++17
0 / 100
6 ms 6236 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]=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(),m=u.size();
    ans.resize(n,0);
    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])
      |            ~~~~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 5724 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 5208 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 6232 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 5724 KB 3rd lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 6236 KB 3rd lines differ - on the 2nd token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 5724 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -