답안 #1045853

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1045853 2024-08-06T08:07:30 Z pcc 장난감 기차 (IOI17_train) C++17
5 / 100
4 ms 1372 KB
#include "train.h"
#include <bits/stdc++.h>
using namespace std;

const int mxn = 5050;

vector<int> charge;
int N,M;
queue<int> q;
int owner[mxn];
bitset<mxn> reach[mxn],dist;
vector<int> paths[mxn];
bitset<mxn> ban;
bitset<mxn> cyc;
bitset<mxn> state;

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++){
		owner[i] = a[i];
		if(r[i]){
			charge.push_back(i);
			ban[i] = true;
		}
	}
	for(int i = 0;i<u.size();i++){
		int aa = u[i],bb = v[i];
		paths[aa].push_back(bb);
	}
	vector<int> ans(N,-1);
	for(int i = N-1;i>=0;i--){
		if(owner[i]){
			ans[i] = 0;
			for(auto nxt:paths[i]){
				if(nxt != i&&state[nxt])ans[i] = 1;
				else if(nxt == i&&ban[i])ans[i] = 1;
			}
		}
		else{
			ans[i] = 1;
			for(auto nxt:paths[i]){
				if(nxt != i&&!state[nxt])ans[i] = 0;
				else if(nxt == i&&!ban[i])ans[i] = 0;
			}
		}
		state[i] = ans[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:26:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |  for(int i = 0;i<u.size();i++){
      |                ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 856 KB Output is correct
2 Correct 2 ms 860 KB Output is correct
3 Correct 2 ms 996 KB Output is correct
4 Correct 2 ms 840 KB Output is correct
5 Correct 2 ms 996 KB Output is correct
6 Correct 2 ms 860 KB Output is correct
7 Correct 2 ms 860 KB Output is correct
8 Correct 2 ms 860 KB Output is correct
9 Correct 2 ms 860 KB Output is correct
10 Correct 2 ms 860 KB Output is correct
11 Correct 1 ms 860 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB 3rd lines differ - on the 2nd token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 1240 KB Output is correct
2 Correct 4 ms 1372 KB Output is correct
3 Correct 3 ms 1372 KB Output is correct
4 Incorrect 3 ms 1372 KB 3rd lines differ - on the 1st token, expected: '1', found: '0'
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 1112 KB 3rd lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 1116 KB 3rd lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 856 KB Output is correct
2 Correct 2 ms 860 KB Output is correct
3 Correct 2 ms 996 KB Output is correct
4 Correct 2 ms 840 KB Output is correct
5 Correct 2 ms 996 KB Output is correct
6 Correct 2 ms 860 KB Output is correct
7 Correct 2 ms 860 KB Output is correct
8 Correct 2 ms 860 KB Output is correct
9 Correct 2 ms 860 KB Output is correct
10 Correct 2 ms 860 KB Output is correct
11 Correct 1 ms 860 KB Output is correct
12 Incorrect 0 ms 344 KB 3rd lines differ - on the 2nd token, expected: '1', found: '0'
13 Halted 0 ms 0 KB -