답안 #884465

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
884465 2023-12-07T12:17:09 Z abcvuitunggio 장난감 기차 (IOI17_train) C++17
11 / 100
7 ms 1624 KB
#include "train.h"
#include <bits/stdc++.h>
using namespace std;
vector <int> ke[5001],res,A,R;
int n,m,deg[5001],d[5001];
queue <int> q;
void bfs(vector <int> ve, int w){
    memset(d,0,sizeof(d));
    for (int i:ve){
        d[i]=1;
        q.push(i);
    }
    while (!q.empty()){
        int u=q.front();
        q.pop();
        for (int v:ke[u])
            if (!d[v]){
                if (A[v]==w||!--deg[v]){
                    d[v]=1;
                    q.push(v);
                }
            }
    }
}
vector <int> who_wins(vector <int> a, vector <int> r, vector <int> u, vector <int> v){
    A=a,n=a.size(),m=u.size();
    res.assign(n,-1);
    while (true){
        R.clear();
        for (int i=0;i<n;i++){
            ke[i].clear();
            deg[i]=0;
            if (r[i]&&res[i]==-1)
                R.push_back(i);
        }
        for (int i=0;i<m;i++)
            if (res[u[i]]==-1&&res[v[i]]==-1){
                ke[v[i]].push_back(u[i]);
                deg[u[i]]++;
            }
        bfs(R,1);
        R.clear();
        for (int i=0;i<n;i++)
            if (res[i]==-1&&!d[i])
                R.push_back(i);
        if (R.empty()){
            for (int i=0;i<n;i++)
                if (d[i])
                    res[i]=1;
            break;
        }
        for (int i=0;i<m;i++)
            if (res[u[i]]==-1&&res[v[i]]==-1)
                deg[u[i]]++;
        bfs(R,0);
        for (int i=0;i<n;i++)
            if (d[i])
                res[i]=0;
    }
    return res;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 856 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 1372 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 1112 KB Output is correct
2 Correct 5 ms 1160 KB Output is correct
3 Correct 6 ms 1272 KB Output is correct
4 Correct 5 ms 1372 KB Output is correct
5 Correct 6 ms 1300 KB Output is correct
6 Correct 5 ms 1372 KB Output is correct
7 Correct 5 ms 1364 KB Output is correct
8 Correct 5 ms 1336 KB Output is correct
9 Correct 5 ms 1348 KB Output is correct
10 Correct 5 ms 1372 KB Output is correct
11 Correct 5 ms 1372 KB Output is correct
12 Correct 5 ms 1472 KB Output is correct
13 Correct 6 ms 1372 KB Output is correct
14 Correct 5 ms 1352 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 1624 KB Output is correct
2 Correct 5 ms 1372 KB Output is correct
3 Correct 6 ms 1372 KB Output is correct
4 Correct 5 ms 1372 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 3 ms 860 KB Output is correct
7 Correct 3 ms 1060 KB Output is correct
8 Incorrect 4 ms 1116 KB 3rd lines differ - on the 5th token, expected: '0', found: '1'
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 856 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -