Submission #1068409

# Submission time Handle Problem Language Result Execution time Memory
1068409 2024-08-21T09:44:57 Z Abito Toy Train (IOI17_train) C++17
5 / 100
4 ms 1324 KB
#include "train.h"
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N=5005;
int n;
bool b[2][N],dp[N],vis[N],a[N],c[N];
bool rec(int x){
	if (vis[x]) return dp[x];
	vis[x]=1;
	if (a[x]){
		if (b[0][x] && c[x]){
			dp[x]=1;
		//	cout<<x<<endl;
		}
		if (b[1][x]){
			if (a[x+1]) dp[x]|=rec(x+1);
			else dp[x]|=!rec(x+1);
		}
	}
	else{
		if (b[0][x] && !c[x]) dp[x]=1;
		if (b[1][x]){
			if (!a[x+1]) dp[x]|=rec(x+1);
			else dp[x]|=!rec(x+1);
		}
	}return dp[x];
}
std::vector<int32_t> who_wins(std::vector<int32_t> A, std::vector<int32_t> r, std::vector<int32_t> u, std::vector<int32_t> v) {
	n=A.size();
	for (int i=1;i<=n;i++) a[i]=A[i-1],c[i]=r[i-1];
	for (int i=0;i<u.size();i++){
		if (v[i]==u[i]) b[0][u[i]+1]=1;
		else b[1][u[i]+1]=1;
	}
	//for (int i=1;i<=n;i++) cout<<b[0][i]<<' '<<b[1][i]<<endl;
	vector<int32_t> ans(n);
	for (int i=0;i<n;i++){
		if (a[i+1]) ans[i]=rec(i+1);
		else ans[i]=!rec(i+1);
	}
	return ans;
}

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:32:16: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |  for (int i=0;i<u.size();i++){
      |               ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 856 KB Output is correct
2 Correct 2 ms 708 KB Output is correct
3 Correct 2 ms 604 KB Output is correct
4 Correct 2 ms 604 KB Output is correct
5 Correct 2 ms 616 KB Output is correct
6 Correct 2 ms 604 KB Output is correct
7 Correct 2 ms 604 KB Output is correct
8 Correct 2 ms 604 KB Output is correct
9 Correct 2 ms 604 KB Output is correct
10 Correct 3 ms 600 KB Output is correct
11 Correct 2 ms 600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 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 Incorrect 3 ms 1000 KB 3rd lines differ - on the 1664th token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 1324 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 4 ms 1112 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 2 ms 856 KB Output is correct
2 Correct 2 ms 708 KB Output is correct
3 Correct 2 ms 604 KB Output is correct
4 Correct 2 ms 604 KB Output is correct
5 Correct 2 ms 616 KB Output is correct
6 Correct 2 ms 604 KB Output is correct
7 Correct 2 ms 604 KB Output is correct
8 Correct 2 ms 604 KB Output is correct
9 Correct 2 ms 604 KB Output is correct
10 Correct 3 ms 600 KB Output is correct
11 Correct 2 ms 600 KB Output is correct
12 Incorrect 0 ms 348 KB 3rd lines differ - on the 2nd token, expected: '1', found: '0'
13 Halted 0 ms 0 KB -