Submission #294376

# Submission time Handle Problem Language Result Execution time Memory
294376 2020-09-08T20:55:16 Z eohomegrownapps Toy Train (IOI17_train) C++14
0 / 100
13 ms 1664 KB
#include "train.h"
#include <bits/stdc++.h>
using namespace std;

int n,m;

vector<vector<int>> adjlist;
vector<vector<int>> revadjlist;

vector<int> aowns;
vector<int> charging;

vector<int> used; // 0 - eliminated, 1 - unvisited, 2 - in f
vector<int> awins;


bool genSet(){
	vector<int> numconnected(n,0);
	queue<int> q;
	for (int i = 0; i<n; i++){
		if (used[i]!=0){
			used[i]=1;
		}
	}
	for (int i = 0; i<n; i++){
		if (!charging[i]){continue;}
		used[i]=2;
		q.push(i);
	}
	while (q.size()>0){
		int f = q.front();
		q.pop();
		for (int i : revadjlist[f]){
			if (used[i]!=1){continue;}
			numconnected[i]++;
			if (aowns[i]||((!aowns[i])&&numconnected[i]==adjlist[i].size())){
				// i is in s
				used[i]=2;
				q.push(i);
			}
		}
	}
	bool bwins = false;
	for (int i = 0; i<n; i++){
		if (used[i]==1){
			awins[i]=0;
			bwins=true;
			used[i]=0;
		}
	}
	if (!bwins){
		for (int i = 0; i<n; i++){
			if (used[i]==2){
				awins[i]=1;
			}
		}
		return true;
	}
	return false;
}

std::vector<int> who_wins(std::vector<int> _aowns, std::vector<int> _charging, std::vector<int> u, std::vector<int> v) {
	aowns=_aowns;
	charging=_charging;
	n=aowns.size();
	m=u.size();
	//cout<<"blah"<<endl;
	//cout<<n<<endl;
	adjlist.resize(n);
	revadjlist.resize(n);
	for (int i = 0; i<m; i++){
		//cout<<u[i]<<' '<<v[i]<<endl;
		adjlist[u[i]].push_back(v[i]);
		revadjlist[v[i]].push_back(u[i]);
	}
	//cout<<"bleh"<<endl;
	awins.resize(n);
	used.resize(n,1);

	while (!genSet()){
		continue;
	}

	return awins;
}

Compilation message

train.cpp: In function 'bool genSet()':
train.cpp:36:47: warning: comparison of integer expressions of different signedness: '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |    if (aowns[i]||((!aowns[i])&&numconnected[i]==adjlist[i].size())){
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 1280 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 384 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 1664 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 1536 KB 3rd lines differ - on the 696th token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 11 ms 1664 KB Output is correct
2 Correct 13 ms 1664 KB Output is correct
3 Correct 11 ms 1664 KB Output is correct
4 Correct 10 ms 1536 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Incorrect 5 ms 1152 KB 3rd lines differ - on the 3730th token, expected: '0', found: '1'
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 1280 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -