답안 #593894

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
593894 2022-07-11T17:20:17 Z FatihSolak 장난감 기차 (IOI17_train) C++17
0 / 100
1327 ms 1060 KB
#include "train.h"
#include <bits/stdc++.h>
#define N 5005
using namespace std;
int dp[N];
int ndp[N];
vector<int> adj[N];
vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u, vector<int> v) {
	int n = a.size();
	int m = u.size();
	for(int i = 0;i<m;i++){
		adj[u[i]].push_back(v[i]);
	}
	for(int i=0;i<4*n;i++){
		for(int j = 0;j<n;j++){
			if(a[j]){
				ndp[j] = -1e18;
				for(auto u:adj[j]){
					ndp[j] = max(ndp[j],dp[u] + r[j]*n - 1);
				}
				ndp[j] = min(ndp[j],n);
			}
			else{
				ndp[j] = 1e18;
				for(auto u:adj[j]){
					ndp[j] = min(ndp[j],dp[u] + r[j]*n - 1);
				}
				if(ndp[j] <= 0){
					ndp[j] = -1e9;
				}
			}
		}
		for(int j = 0;j<n;j++){
			dp[j] = ndp[j];
		}
	}
	vector<int> res(n);
	for(int i = 0; i < n; i++){
		res[i] = (dp[i] > 0);
	}
	return res;
}

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:17:14: warning: overflow in conversion from 'double' to 'int' changes value from '-1.0e+18' to '-2147483648' [-Woverflow]
   17 |     ndp[j] = -1e18;
      |              ^~~~~
train.cpp:24:14: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+18' to '2147483647' [-Woverflow]
   24 |     ndp[j] = 1e18;
      |              ^~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 584 ms 768 KB 3rd lines differ - on the 26th token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 340 KB 3rd lines differ - on the 2nd token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 979 ms 1060 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1056 ms 916 KB 3rd lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1327 ms 980 KB 3rd lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 584 ms 768 KB 3rd lines differ - on the 26th token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -