Submission #704014

# Submission time Handle Problem Language Result Execution time Memory
704014 2023-03-01T11:22:09 Z Abrar_Al_Samit Toy Train (IOI17_train) C++17
27 / 100
2000 ms 1864 KB
#include<bits/stdc++.h>
#include "train.h"
using namespace std;

const int nax = 5000;
int n, m;
vector<int>g[nax], gt[nax];
vector<int>A, R;

vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u, vector<int> v) {
	n = a.size(), m = u.size();
	for(int i=0; i<m; ++i) {
		g[u[i]].push_back(v[i]);
		gt[v[i]].push_back(u[i]);
	}

	A = a, R = r;
	vector<int>res(n);

	while(1) {
		set<int>nontrap, trap;
		for(int i=0; i<n; ++i) {
			if(R[i]) nontrap.insert(i);
			else trap.insert(i);
		}


		vector<int>trans;

		while(1) {
			for(int x : trap) {
				bool all = true, one = false;
				for(int to : g[x]) {
					all &= nontrap.count(to);
					one |= nontrap.count(to);
				}
				if(A[x] && one) {
					trans.push_back(x);
				} else if(!A[x] && all) {
					trans.push_back(x);
				}
			}
			if(trans.empty()) break;
			for(int x : trans) {
				trap.erase(x);
				nontrap.insert(x);
			}
			trans.clear();
		}

		for(int x : nontrap) {
			bool all = true, one = false;
			for(int to : g[x]) {
				all &= trap.count(to);
				one |= trap.count(to);
			}

			if(A[x] && all) {
				trans.push_back(x);
			} else if(!A[x] && one) {
				trans.push_back(x);
			}
		}
		if(trans.empty()) {
			for(int x : nontrap) res[x] = 1;
			break;
		}
		for(int x : trans) {
			trap.insert(x);
			nontrap.erase(x);
			R[x] = 0;
		}
	}
	return res;
}
# Verdict Execution time Memory Grader output
1 Correct 61 ms 1404 KB Output is correct
2 Correct 62 ms 1364 KB Output is correct
3 Correct 69 ms 1404 KB Output is correct
4 Correct 81 ms 1364 KB Output is correct
5 Correct 60 ms 1364 KB Output is correct
6 Correct 75 ms 1392 KB Output is correct
7 Correct 58 ms 1320 KB Output is correct
8 Correct 40 ms 1364 KB Output is correct
9 Correct 31 ms 1388 KB Output is correct
10 Correct 15 ms 1344 KB Output is correct
11 Correct 6 ms 1364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 468 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 1 ms 468 KB Output is correct
7 Correct 1 ms 540 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 1 ms 468 KB Output is correct
10 Correct 1 ms 536 KB Output is correct
11 Correct 1 ms 544 KB Output is correct
12 Correct 1 ms 468 KB Output is correct
13 Correct 1 ms 532 KB Output is correct
14 Correct 1 ms 468 KB Output is correct
15 Correct 1 ms 540 KB Output is correct
16 Correct 1 ms 468 KB Output is correct
17 Correct 1 ms 468 KB Output is correct
18 Correct 1 ms 544 KB Output is correct
19 Correct 1 ms 540 KB Output is correct
20 Correct 1 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 2052 ms 1832 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 14 ms 1620 KB Output is correct
2 Correct 128 ms 1712 KB Output is correct
3 Correct 102 ms 1816 KB Output is correct
4 Correct 88 ms 1832 KB Output is correct
5 Execution timed out 2031 ms 1824 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 72 ms 1832 KB Output is correct
2 Correct 18 ms 1864 KB Output is correct
3 Correct 39 ms 1832 KB Output is correct
4 Correct 28 ms 1744 KB Output is correct
5 Correct 2 ms 596 KB Output is correct
6 Correct 7 ms 1348 KB Output is correct
7 Correct 24 ms 1188 KB Output is correct
8 Correct 8 ms 1192 KB Output is correct
9 Correct 20 ms 1256 KB Output is correct
10 Correct 4 ms 756 KB Output is correct
11 Correct 24 ms 1172 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 61 ms 1404 KB Output is correct
2 Correct 62 ms 1364 KB Output is correct
3 Correct 69 ms 1404 KB Output is correct
4 Correct 81 ms 1364 KB Output is correct
5 Correct 60 ms 1364 KB Output is correct
6 Correct 75 ms 1392 KB Output is correct
7 Correct 58 ms 1320 KB Output is correct
8 Correct 40 ms 1364 KB Output is correct
9 Correct 31 ms 1388 KB Output is correct
10 Correct 15 ms 1344 KB Output is correct
11 Correct 6 ms 1364 KB Output is correct
12 Correct 1 ms 468 KB Output is correct
13 Correct 1 ms 468 KB Output is correct
14 Correct 1 ms 468 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Correct 1 ms 468 KB Output is correct
17 Correct 1 ms 468 KB Output is correct
18 Correct 1 ms 540 KB Output is correct
19 Correct 1 ms 468 KB Output is correct
20 Correct 1 ms 468 KB Output is correct
21 Correct 1 ms 536 KB Output is correct
22 Correct 1 ms 544 KB Output is correct
23 Correct 1 ms 468 KB Output is correct
24 Correct 1 ms 532 KB Output is correct
25 Correct 1 ms 468 KB Output is correct
26 Correct 1 ms 540 KB Output is correct
27 Correct 1 ms 468 KB Output is correct
28 Correct 1 ms 468 KB Output is correct
29 Correct 1 ms 544 KB Output is correct
30 Correct 1 ms 540 KB Output is correct
31 Correct 1 ms 468 KB Output is correct
32 Execution timed out 2052 ms 1832 KB Time limit exceeded
33 Halted 0 ms 0 KB -