답안 #775972

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
775972 2023-07-07T07:56:36 Z PoonYaPat 장난감 기차 (IOI17_train) C++14
0 / 100
1759 ms 1588 KB
#include "train.h"
#include <bits/stdc++.h>
using namespace std;

int n;
bool c[5005],charge[5005],vis[5005];
vector<int> adj[5005],radj[5005],ans;

void dfs(int x) {
	for (auto s : adj[x]) {
		if (!vis[s] && !charge[s]) {
			vis[s]=true;
			dfs(s);
		}
	}
}

void rdfs(int x) {
	vis[x]=true;
	ans[x]=0;
	for (auto s : radj[x]) {
		if (!vis[s] && !charge[s]) {
			rdfs(s);
		}
	}
}

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<n; ++i) charge[i]=r[i], c[i]=a[i], ans.push_back(1);

	for (int i=0; i<u.size(); ++i) {
		adj[u[i]].push_back(v[i]);
		radj[v[i]].push_back(u[i]);
	}

	for (int i=0; i<n; ++i) {
		if (charge[i]) continue;

		memset(vis,0,sizeof(vis));
		dfs(i);
		if (!vis[i]) continue;

		memset(vis,0,sizeof(vis));
		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:33:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |  for (int i=0; i<u.size(); ++i) {
      |                ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 980 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 468 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 60 ms 1588 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 1236 KB 3rd lines differ - on the 696th token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1759 ms 1492 KB 3rd lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 980 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -