Submission #429291

#TimeUsernameProblemLanguageResultExecution timeMemory
429291Dremix10Toy Train (IOI17_train)C++17
0 / 100
10 ms1484 KiB
#include "train.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef unsigned long long ull; typedef pair<int,int> pi; typedef pair<ll,ll> pl; #define F first #define S second #define endl '\n' #define all(x) (x).begin(),(x).end() #ifdef dremix #define p(x) cerr<<#x<<" = "<<x<<endl; #define p2(x,y) cerr<<#x<<", "<<#y<<" = {"<<x<<", "<<y<<"}"<<endl; #define pp(x) cerr<<#x<<" = "<<"("<<x.F<<" - "<<x.S<<")"<<endl; #define pv(x) cerr<<#x<<" = "<<"{";for(auto y : x)cerr<<y<<", ";cerr<<"}"<<endl; #define ppv(x) cerr<<#x<<" = "<<"{";for(auto y : x)cerr<<y.F<<"-"<<y.S<<", ";cerr<<"}"<<endl; #else #define p(x) #define p2(x,y) #define pp(x) #define pv(x) #define ppv(x) #endif #define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); const int maxp = 22; const ld EPS = 1e-9; const ll INF = 1e18; const int MOD = 1e9+7; const int N = 5001; vector<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(); int i,j; for(i=0;i<m;i++){ int x = u[i]; int y = v[i]; assert(x<=y); adj[x].push_back(y); } vector<int> ans(n); for(i=0;i<n;i++){ bool self = false; bool nxt = false; for(auto x : adj[i]) if(x==i)self = true; else nxt = true; bool win = false; if(a[i] && self && r[i]) win = true; if(i>0 && a[i] && ans[i-1] && nxt) win = true; if((!self || self && r[i]) && (i==0 || !nxt || nxt && i>0 && ans[i-1])) win = true; ans[i] = win; } return ans; /* g++ grader.cpp trainSub.cpp -Ddremix */ }

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:63:27: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   63 |         if((!self || self && r[i]) && (i==0 || !nxt || nxt && i>0 && ans[i-1]))
train.cpp:63:67: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   63 |         if((!self || self && r[i]) && (i==0 || !nxt || nxt && i>0 && ans[i-1]))
train.cpp:39:11: warning: unused variable 'j' [-Wunused-variable]
   39 |     int i,j;
      |           ^
#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...