Submission #575479

# Submission time Handle Problem Language Result Execution time Memory
575479 2022-06-10T18:36:05 Z definitelynotmee Toy Train (IOI17_train) C++
23 / 100
189 ms 1696 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(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 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 Correct 53 ms 1620 KB Output is correct
2 Correct 83 ms 1696 KB Output is correct
3 Correct 100 ms 1660 KB Output is correct
4 Correct 14 ms 1492 KB Output is correct
5 Correct 11 ms 1512 KB Output is correct
6 Correct 14 ms 1400 KB Output is correct
7 Correct 10 ms 1364 KB Output is correct
8 Correct 7 ms 1380 KB Output is correct
9 Correct 6 ms 1364 KB Output is correct
10 Correct 7 ms 1348 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 1556 KB Output is correct
14 Correct 7 ms 1492 KB Output is correct
15 Correct 7 ms 1528 KB Output is correct
16 Correct 7 ms 1492 KB Output is correct
17 Correct 7 ms 1580 KB Output is correct
18 Correct 189 ms 1336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 12 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 Correct 10 ms 1388 KB Output is correct
2 Correct 8 ms 1492 KB Output is correct
3 Correct 8 ms 1340 KB Output is correct
4 Correct 8 ms 1352 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 4 ms 980 KB Output is correct
7 Correct 6 ms 852 KB Output is correct
8 Correct 4 ms 852 KB Output is correct
9 Correct 5 ms 976 KB Output is correct
10 Correct 1 ms 468 KB Output is correct
11 Correct 4 ms 852 KB Output is correct
# 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 -