Submission #575476

# Submission time Handle Problem Language Result Execution time Memory
575476 2022-06-10T18:17:40 Z definitelynotmee Toy Train (IOI17_train) C++
11 / 100
183 ms 1704 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.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(grau[i] == 0)
					continue;
				if(a[i] == 1){
					grau[i] = 0;
				} else grau[i]--;
				if(grau[i] == 0){
					win[i] = 1;
					if(i != v)
						f(i,f);
				}
			}
		};

		if(!win[v])
			processwin(v,processwin);
		if(win[v]){
			swap(resp,win);
			swap(grau,degree);
		}
	}

	return resp;
}
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 1108 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 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 Correct 52 ms 1704 KB Output is correct
2 Correct 84 ms 1692 KB Output is correct
3 Correct 102 ms 1620 KB Output is correct
4 Correct 9 ms 1492 KB Output is correct
5 Correct 11 ms 1488 KB Output is correct
6 Correct 14 ms 1440 KB Output is correct
7 Correct 11 ms 1392 KB Output is correct
8 Correct 7 ms 1360 KB Output is correct
9 Correct 7 ms 1364 KB Output is correct
10 Correct 7 ms 1384 KB Output is correct
11 Correct 6 ms 1364 KB Output is correct
12 Correct 6 ms 1236 KB Output is correct
13 Correct 7 ms 1496 KB Output is correct
14 Correct 8 ms 1492 KB Output is correct
15 Correct 8 ms 1512 KB Output is correct
16 Correct 7 ms 1492 KB Output is correct
17 Correct 7 ms 1492 KB Output is correct
18 Correct 183 ms 1288 KB Output is correct
# 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 7 ms 1376 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 7 ms 1108 KB 3rd lines differ - on the 14th token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -