Submission #711551

# Submission time Handle Problem Language Result Execution time Memory
711551 2023-03-17T08:28:02 Z penguinman Toy Train (IOI17_train) C++17
11 / 100
543 ms 1636 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> who_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]);
	vii edge_mem = edge;
	vi dp = r;
	REP(t,0,N+10){
		rep(i,0,N){
			if(a[i] == 1){
				for(auto next: edge[i]){
					dp[i] |= dp[next];
				}
			}
			else{
				int idx = 0;
				while(idx < edge[i].size()){
					int next = edge[i][idx];
					if(dp[next]){
						int length = edge[i].size();
						std::swap(edge[i][idx], edge[i][length-1]);
						edge[i].pop_back();
					}
					else idx++;
				}
				if(edge[i].empty()) dp[i] = 1;
			}
		}
	}
	edge = edge_mem;
	vi dp2 = dp;
	rep(i,0,N) dp2[i] = 1-dp2[i];
	REP(t,0,N+10){
		rep(i,0,N){
			if(a[i] == 0){
				for(auto next: edge[i]){
					dp2[i] |= dp2[next];
				}
			}
			else{
				int idx = 0;
				while(idx < edge[i].size()){
					int next = edge[i][idx];
					if(dp2[next]){
						int length = edge[i].size();
						std::swap(edge[i][idx], edge[i][length-1]);
						edge[i].pop_back();
					}
					else idx++;
				}
				if(edge[i].empty()) dp2[i] = 1;
			}
		}
	}
	rep(i,0,N) dp2[i] = 1-dp2[i];
	return dp2;
}

Compilation message

train.cpp: In function 'std::vector<int> who_wins(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
train.cpp:36:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |     while(idx < edge[i].size()){
      |           ~~~~^~~~~~~~~~~~~~~~
train.cpp:61:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   61 |     while(idx < edge[i].size()){
      |           ~~~~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 253 ms 1048 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 280 KB Output is correct
4 Incorrect 0 ms 212 KB 3rd lines differ - on the 4th token, expected: '0', found: '1'
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 337 ms 1392 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 237 ms 1188 KB Output is correct
2 Correct 331 ms 1396 KB Output is correct
3 Correct 504 ms 1628 KB Output is correct
4 Correct 461 ms 1612 KB Output is correct
5 Correct 425 ms 1492 KB Output is correct
6 Correct 374 ms 1516 KB Output is correct
7 Correct 401 ms 1504 KB Output is correct
8 Correct 494 ms 1484 KB Output is correct
9 Correct 306 ms 1416 KB Output is correct
10 Correct 285 ms 1500 KB Output is correct
11 Correct 291 ms 1500 KB Output is correct
12 Correct 287 ms 1492 KB Output is correct
13 Correct 464 ms 1636 KB Output is correct
14 Correct 359 ms 1436 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 522 ms 1300 KB Output is correct
2 Correct 538 ms 1288 KB Output is correct
3 Correct 543 ms 1276 KB Output is correct
4 Correct 480 ms 1244 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 266 ms 1040 KB Output is correct
7 Correct 21 ms 852 KB Output is correct
8 Incorrect 22 ms 996 KB 3rd lines differ - on the 5th token, expected: '0', found: '1'
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 253 ms 1048 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -