Submission #286165

# Submission time Handle Problem Language Result Execution time Memory
286165 2020-08-30T07:46:27 Z user202729 Toy Train (IOI17_train) C++17
0 / 100
6 ms 896 KB
// moreflags=grader.cpp
//
// 13
// ...
#include "train.h"

std::vector<int> who_wins(std::vector<int> a, std::vector<int> r, std::vector<int> u, std::vector<int> v) {
	if(a.size()>15) return {};
	std::vector<int> adjacent(a.size());
	for(int index=0; index<(int)u.size(); ++index){
		adjacent[u[index]]|=1<<v[index];
	}

	int noChargeMask=0;
	for(int node=0; node<(int)r.size(); ++node)
		if(not r[node])
			noChargeMask|=1<<node;

	auto const contains=[&](int large, int small){ return (large&small)==small; };

	int bwin{};
	for(int mask=noChargeMask; mask; mask=(mask-1)&noChargeMask){
		for(int node=0; node<(int)a.size(); ++node)
			if(mask>>node&1){
				if(a[node]){
					if(not contains(mask, adjacent[node]))
						goto next_mask;
				}else{
					if((mask&adjacent[node])==0)
						goto next_mask;
				}
			}
		bwin|=mask;
next_mask:;
	}

	for(int _=0; _<(int)a.size(); ++_){
		for(int node=0; node<(int)a.size(); ++node)
			if(a[node]){
				if(contains(bwin, adjacent[node])) bwin|=1<<node;
			}else{
				if((bwin&adjacent[node])!=0) bwin|=1<<node;
			}
	}

	std::vector<int> result(a.size());
	for(int node=0; node<(int)a.size(); ++node)
		result[node]=not(bwin>>node&1);
	return result;
}
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 512 KB WA in grader: Wrong returned array size
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Incorrect 0 ms 256 KB 3rd lines differ - on the 4th token, expected: '0', found: '1'
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 896 KB WA in grader: Wrong returned array size
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 768 KB WA in grader: Wrong returned array size
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 896 KB WA in grader: Wrong returned array size
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 512 KB WA in grader: Wrong returned array size
2 Halted 0 ms 0 KB -