Submission #1068409

#TimeUsernameProblemLanguageResultExecution timeMemory
1068409AbitoToy Train (IOI17_train)C++17
5 / 100
4 ms1324 KiB
#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 (stderr)

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...