Submission #1045560

# Submission time Handle Problem Language Result Execution time Memory
1045560 2024-08-06T05:42:58 Z pcc Toy Train (IOI17_train) C++17
0 / 100
507 ms 4516 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];

void BFS(int s = -1){
	if(s != -1){
		dist.reset();
		q.push(s);
	}
	while(!q.empty()){
		auto now = q.front();
		q.pop();
		for(auto nxt:paths[now]){
			if(!dist[nxt]){
				dist[nxt] = 1;
				q.push(nxt);
			}
		}
	}
	return;
}

std::vector<int> who_wins(std::vector<int> a, std::vector<int> r, std::vector<int> u, std::vector<int> v) {
	N = a.size();
	assert(r.size() == a.size());
	for(int i = 0;i<N;i++){
		owner[i] = a[i];
		if(r[i])charge.push_back(i);
	}
	for(int i = 0;i<u.size();i++){
		int aa = u[i],bb = v[i];
		paths[aa].push_back(bb);
	}
	for(int i = 0;i<N;i++){
		BFS(i);
		reach[i] = dist;
	}
	vector<int> ans(N);
	for(int i = 0;i<N;i++){
		for(auto &j:charge){
			if(reach[i][j]&&reach[j][i])ans[i] = 1;
		}
	}
	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:39:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |  for(int i = 0;i<u.size();i++){
      |                ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 90 ms 3924 KB 3rd lines differ - on the 14th token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB 3rd lines differ - on the 8th token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 78 ms 4432 KB Output is correct
2 Correct 84 ms 4432 KB Output is correct
3 Correct 95 ms 4516 KB Output is correct
4 Incorrect 507 ms 4436 KB 3rd lines differ - on the 13th token, expected: '1', found: '0'
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 448 ms 4180 KB 3rd lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 505 ms 4512 KB 3rd lines differ - on the 2nd token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 90 ms 3924 KB 3rd lines differ - on the 14th token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -