Submission #575478

# Submission time Handle Problem Language Result Execution time Memory
575478 2022-06-10T18:34:37 Z definitelynotmee Toy Train (IOI17_train) C++
0 / 100
2000 ms 1620 KB
#include<bits/stdc++.h>
#include"train.h"
#define mp make_pair
#define mt make_tuple
#define all(x) x.begin(), x.end()
#define ff first
#define ss second
using namespace std;
template <typename T>
using matrix = vector<vector<T>>;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll INFL = (1LL<<62)-1;
const int INF = (1<<30)-1;
const double EPS = 1e-7;
const int MOD = 1e9 + 7;
const int RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
const int MAXN = 1e6+1;


std::vector<int> who_wins(std::vector<int> a, std::vector<int> r, std::vector<int> u, std::vector<int> v) {

	int n = a.size(), m = u.size();
	matrix<int> g(n), rev(n);
	for(int i = 0; i < m; i++){
		g[u[i]].push_back(v[i]);
		rev[v[i]].push_back(u[i]);
	}
	vector<int> resp(n);
	vector<int> degree(n);
	for(int i = 0; i < n; i++)
		degree[i] = g[i].size();
	for(int v = 0; v < n; v++){
		if(!r[v])
			continue;

		vector<int> win = resp, grau = degree;
		auto processwin = [&](int id, auto f)->void{
			for(int i : rev[id]){
				if(a[i] == 1 && grau[i] != 0){
					grau[i] = 0;
				} else grau[i]--;
				if(grau[i] == 0){
					win[i] = 1;
					if(i != v)
						f(i,f);
				}
			}
		};
		processwin(v,processwin);
		if(win[v]){
			swap(resp,win);
			swap(grau,degree);
		}
		// cout << v << ":\n";
		// for(int i = 0; i < n; i++)
		// 	cout << grau[i] << ' ';
		// cout << '\n';
	}

	return resp;
}
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 1108 KB 3rd lines differ - on the 26th token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB 3rd lines differ - on the 2nd token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2081 ms 1620 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 11 ms 1236 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 8 ms 1364 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 7 ms 1108 KB 3rd lines differ - on the 26th token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -