답안 #432630

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
432630 2021-06-18T11:46:03 Z Runtime_error_ 장난감 기차 (IOI17_train) C++14
0 / 100
11 ms 1228 KB
 #include "train.h"
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
const int inf = 5e3+9;
int n,m;
vector<int> adj[inf];
bool vis[inf],station[inf],NoStationCycle[inf];

bool incycle(int u,int goal){
    bool ret = 0;
    vis[u] = 1;
    if(station[u])
        return 0;
    for(auto v:adj[u]){
        if(v == goal)
            return ret = 1;
        if(!vis[v])
            ret |= incycle(v,goal);
    }
    return ret;
}

bool findstation(int u){
    bool ret = 0;
    if(NoStationCycle[u])
        return ret = 1;
    vis[u] = 1;
    for(auto v:adj[u])
        if(!vis[v])
            ret |= findstation(v);
    return ret;
}

vector<int> who_wins(vector<int> a, vector<int> R, vector<int> U, vector<int> V) {
    vector<int> ret;
    n = a.size();m  = U.size();
    for(int i=0;i<m;i++)
        adj[U[i]].pb(V[i]);

    for(int i=0;i<n;i++)
        station[i] = R[i];
    for(int i=0;i<n;i++){
        memset(vis,0,sizeof(vis));
        NoStationCycle[i] = incycle[i];
    }
    for(int i=0;i<n;i++){
        memset(vis,0,sizeof(vis));
        ret.pb(!findstation(i));
    }
    return ret;
}
/*
2 4
0 0
1 0
0 1
1 0
1 1
0 0
*/

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:46:38: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   46 |         NoStationCycle[i] = incycle[i];
      |                                      ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 844 KB 3rd lines differ - on the 14th token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 332 KB 3rd lines differ - on the 2nd token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 1228 KB Output is correct
2 Correct 8 ms 1228 KB Output is correct
3 Correct 10 ms 1188 KB Output is correct
4 Incorrect 9 ms 1228 KB 3rd lines differ - on the 1st token, expected: '1', found: '0'
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 11 ms 1100 KB 3rd lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 9 ms 1228 KB 3rd lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 844 KB 3rd lines differ - on the 14th token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -