답안 #1037597

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1037597 2024-07-29T05:30:36 Z 12345678 장난감 기차 (IOI17_train) C++17
11 / 100
376 ms 1736 KB
#include "train.h"
#include <bits/stdc++.h>

using namespace std;

const int nx=5e3+5;

int n, cy[nx], pa[nx], vs[nx], f;
vector<int> d[nx], rv[nx];

void dfs(int u, int rt)
{
    vs[u]=1;
    if (f) return;
    for (auto v:d[u])
    {
        if (!f&&v==rt)
        {
            int tmp=u;
            while (tmp!=rt) cy[tmp]=1, tmp=pa[tmp];
            cy[rt]=1;
            f=1;
            return;
        }
        if (vs[v]) continue;
        pa[v]=u;
        dfs(v, rt);
    }
}
std::vector<int> who_wins(std::vector<int> a, std::vector<int> r, std::vector<int> u, std::vector<int> v) {
    n=a.size();
    for (int i=0; i<u.size(); i++) d[u[i]].push_back(v[i]), rv[v[i]].push_back(u[i]);
    for (int i=0; i<n; i++) 
    {
        if (r[i]) 
        {
            f=0;
            for (int j=0; j<n;j ++) vs[j]=0;
            dfs(i, i);    
        }
    }
    vector<int> res(n);
    queue<int> q;
    for (int i=0; i<n;i ++) vs[i]=0;
    for (int i=0; i<n;i ++) if (cy[i]) q.push(i), vs[i]=1;
    while (!q.empty())
    {
        auto cur=q.front();
        q.pop();
        res[cur]=1;
        for (auto x:rv[cur]) if (!vs[x]) vs[x]=1,q.push(x);
    }
    return res;
}

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:32:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |     for (int i=0; i<u.size(); i++) d[u[i]].push_back(v[i]), rv[v[i]].push_back(u[i]);
      |                   ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 75 ms 1508 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 604 KB 3rd lines differ - on the 8th token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 1644 KB Output is correct
2 Correct 19 ms 1696 KB Output is correct
3 Correct 43 ms 1736 KB Output is correct
4 Correct 145 ms 1624 KB Output is correct
5 Correct 22 ms 1648 KB Output is correct
6 Correct 50 ms 1548 KB Output is correct
7 Correct 134 ms 1532 KB Output is correct
8 Correct 5 ms 1368 KB Output is correct
9 Correct 4 ms 1376 KB Output is correct
10 Correct 7 ms 1352 KB Output is correct
11 Correct 4 ms 1416 KB Output is correct
12 Correct 8 ms 1368 KB Output is correct
13 Correct 5 ms 1628 KB Output is correct
14 Correct 5 ms 1628 KB Output is correct
15 Correct 5 ms 1628 KB Output is correct
16 Correct 5 ms 1368 KB Output is correct
17 Correct 5 ms 1628 KB Output is correct
18 Correct 118 ms 1472 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 376 ms 1616 KB 3rd lines differ - on the 696th token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 1372 KB 3rd lines differ - on the 2nd token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 75 ms 1508 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -