Submission #711811

# Submission time Handle Problem Language Result Execution time Memory
711811 2023-03-17T14:31:40 Z penguinman Toy Train (IOI17_train) C++17
5 / 100
7 ms 1244 KB
#include "train.h"
#include <bits/stdc++.h>

using std::cin;
using std::cout;
using std::vector;
using ll = int;
using vi = vector<ll>;
using vii = vector<vi>;
using std::string;
using pii = std::pair<ll,ll>;

#define rep(i,j,k) for(ll i=ll(j); i<ll(k); i++)
#define REP(i,j,k) for(ll i=ll(j); i<=ll(k); i++)
#define per(i,j,k) for(ll i=ll(j); i>=ll(k); i--)
#define ln "\n"
#define all(a) a.begin(), a.end()
#define mp std::make_pair
#define pb emplace_back

std::vector<int> wa_wins(std::vector<int> a, std::vector<int> r, std::vector<int> u, std::vector<int> v) {
	ll N = a.size();
	vii edge(N);
	rep(i,0,u.size()) edge[u[i]].pb(v[i]);
	vi dp = r;
	REP(t,0,N+100){
		rep(i,0,N){
			if(a[i] == 1){
				for(auto next: edge[i]){
					dp[i] |= dp[next];
				}
			}
			else{
				int val = 1;
				for(auto next: edge[i]){
					val &= dp[next];
				}
				dp[i] |= val;
			}
		}
	}
	rep(i,0,N) dp[i] = 1-dp[i];
	REP(t,0,N+100){
		rep(i,0,N){
			if(a[i] == 0){
				for(auto next: edge[i]){
					dp[i] |= dp[next];
				}
			}
			else{
				int val = 1;
				for(auto next: edge[i]){
					val &= dp[next];
				}
				dp[i] |= val;
			}
		}
	}
	rep(i,0,N) dp[i] = 1-dp[i];
	return dp;
}


std::vector<int> who_wins(std::vector<int> a, std::vector<int> r, std::vector<int> u, std::vector<int> v) {
	ll N = a.size();
	vi dp(N);
	vii edge(N);
	rep(i,0,u.size()) edge[u[i]].pb(v[i]);
	per(i,N-1,0){
		if(edge[i].size() == 1 && edge[i][0] == i){
			dp[i] = r[i];
		}
		else if(edge[i].size() == 2){
			if(a[i] == 1){
				dp[i] = dp[i+1]|r[i];
			}
			else{
				dp[i] = dp[i+1]&r[i];
			}
		}
		else{
			dp[i] = dp[i+1];
		}
	}
	return dp;
}
# Verdict Execution time Memory Grader output
1 Correct 4 ms 824 KB Output is correct
2 Correct 5 ms 820 KB Output is correct
3 Correct 4 ms 852 KB Output is correct
4 Correct 4 ms 852 KB Output is correct
5 Correct 3 ms 820 KB Output is correct
6 Correct 3 ms 852 KB Output is correct
7 Correct 3 ms 852 KB Output is correct
8 Correct 4 ms 852 KB Output is correct
9 Correct 3 ms 852 KB Output is correct
10 Correct 3 ms 828 KB Output is correct
11 Correct 3 ms 724 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 296 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 7 ms 1208 KB Output is correct
2 Correct 7 ms 1244 KB Output is correct
3 Correct 7 ms 1236 KB Output is correct
4 Incorrect 6 ms 1236 KB 3rd lines differ - on the 872nd token, expected: '1', found: '0'
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 1076 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 1204 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 4 ms 824 KB Output is correct
2 Correct 5 ms 820 KB Output is correct
3 Correct 4 ms 852 KB Output is correct
4 Correct 4 ms 852 KB Output is correct
5 Correct 3 ms 820 KB Output is correct
6 Correct 3 ms 852 KB Output is correct
7 Correct 3 ms 852 KB Output is correct
8 Correct 4 ms 852 KB Output is correct
9 Correct 3 ms 852 KB Output is correct
10 Correct 3 ms 828 KB Output is correct
11 Correct 3 ms 724 KB Output is correct
12 Incorrect 1 ms 296 KB 3rd lines differ - on the 2nd token, expected: '1', found: '0'
13 Halted 0 ms 0 KB -