#include <bits/stdc++.h>
using namespace std;
#define dbgv(v) cout<<#v<<" = "; f(i,0,v.size()) cout<<v[i]<<" "; cout<<endl
#define dbga(a,x,y) cout<<#a<<" = "; f(i,x,y) cout<<a[i]<<" "; cout<<endl
#define erorp(x) cout<<#x<<"={"<<x.F<<" , "<<x.S<<"}"<<endl
#define eror(x) cout<<#x<<'='<<(x)<<endl
#define f_(i,a,b) for(int i=a;i>=b;i--)
#define f(i,a,b) for(int i=a;i<b;i++)
#define nb(x) __builtin_popcount(x)
#define all(v) v.begin(),v.end()
#define bit(n,k) (((n)>>(k))&1)
#define Add(x,y) x=(x+y)%mod
#define maxm(a,b) a=max(a,b)
#define minm(a,b) a=min(a,b)
#define lst(x) x[x.size()-1]
#define sz(x) int(x.size())
#define mp make_pair
#define ll long long
#define pb push_back
#define S second
#define F first
#include "train.h"
const int N=5050;
int n,A[N],B[N],dp[N],vis[N],nxt[N],now[N];
vector<int> g[N];
bool dfs(int u,int rt){
vis[u]=1;
for(auto v : g[u]){
if(v==rt) return 1;
if(vis[v]) continue ;
if(dfs(v,rt)) return 1;
}
return 0;
}
bool check(int u){
fill(vis,vis+N,0);
return dfs(u,u);
}
vector<int> who_wins(vector<int> a,vector<int> r,vector<int> u,vector<int> v){
n=a.size();
f(i,0,u.size()){
if(u[i]==v[i]) nxt[u[i]]=1;
else now[u[i]]=1;
}
f_(u,n-1,0){
if(nxt[u]==0) dp[u]=r[u];
else if(now[u]==0) dp[u]=dp[u+1];
else{
if(now[u]==1 && a[u]==r[u]){
dp[u]=a[u];
}
else{
dp[u]=dp[u+1];
}
}
}
vector<int> ans(n);
f(i,0,n) ans[i]=dp[i];
return ans;
}
/*
int32_t main(){
ios:: sync_with_stdio(0), cin.tie(0), cout.tie(0);
who_wins({1,1},{1,0},{0,0,1,1},{0,1,0,1});
}*/
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:8:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
8 | #define f(i,a,b) for(int i=a;i<b;i++)
......
44 | f(i,0,u.size()){
| ~~~~~~~~~~~~
train.cpp:44:2: note: in expansion of macro 'f'
44 | f(i,0,u.size()){
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
596 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 |
Incorrect |
0 ms |
340 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 |
Incorrect |
5 ms |
852 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 |
Incorrect |
4 ms |
724 KB |
3rd lines differ - on the 21st token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
880 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 |
3 ms |
596 KB |
3rd lines differ - on the 1st token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |