답안 #775920

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
775920 2023-07-07T07:11:07 Z ttamx 장난감 기차 (IOI17_train) C++14
0 / 100
2000 ms 262144 KB
#include "train.h"
#include<bits/stdc++.h>

using namespace std;

vector<int> who_wins(vector<int> a, vector<int> r, vector<int> U, vector<int> V) {
	int n=a.size();
    vector<int> ans(n,1);
    vector<vector<int>> adj(n),radj(n);
    for(int i=0;i<U.size();i++){
        int u=U[i],v=V[i];
        adj[u].emplace_back(v);
        radj[v].emplace_back(u);
    }
    for(int i=0;i<n;i++){
        if(r[i])continue;
        vector<bool> vis(n);
        function<void(int)> dfs=[&](int u){
            for(auto v:adj[u]){
                if(!vis[v]||r[v]){
                    vis[v]=true;
                    dfs(v);
                }
            }
        };
        dfs(i);
        if(!vis[i])continue;
        vector<bool> rvis(n);
        function<void(int)> rdfs=[&](int u){
            if(rvis[u])return;
            rvis[u]=true;
            ans[u]=0;
            for(auto v:radj[u])rdfs(v);
        };
        rdfs(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:10:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |     for(int i=0;i<U.size();i++){
      |                 ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 127 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 123 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 309 ms 1708 KB Output is correct
2 Correct 386 ms 1700 KB Output is correct
3 Correct 442 ms 1680 KB Output is correct
4 Execution timed out 2065 ms 1492 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 142 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2074 ms 1500 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 127 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -