제출 #282361

#제출 시각아이디문제언어결과실행 시간메모리
282361MohamedAhmed04장난감 기차 (IOI17_train)C++14
0 / 100
27 ms18168 KiB
#include <bits/stdc++.h> #include "train.h" //#include "grader.cpp" using namespace std ; const int MAX = 16 ; int A[MAX] , R[MAX] ; vector< vector<int> >adj(MAX) ; int n ; int vis[MAX] , mark[MAX] ; int dp[16][(1 << MAX)][2] ; bool dfs(int node , int mask , bool flag) { int &ret = dp[node][mask][flag] ; if(ret != -1) return ret ; ret = 0 ; for(auto &child : adj[node]) { if((mask & (1 << child))) { if(flag == A[node]) ret = 1 ; continue ; } bool t = dfs(child , mask | (1 << child) , flag | R[child]) ; if(A[node] && A[child] == t) ret = 1 ; else if(!A[node] && A[child] != t) ret = 1 ; } return ret ; } vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u, vector<int> v) { memset(dp , -1 , sizeof(dp)) ; n = a.size() ; int m = u.size() ; n = a.size() ; m = u.size() ; for(int i = 0 ; i < n ; ++i) A[i] = a[i] , R[i] = r[i] ; for(int i = 0 ; i < m ; ++i) adj[u[i]].push_back(v[i]) ; vector<int>ans ; for(int i = 0 ; i < n ; ++i) { bool t = dfs(i , 1 << i , r[i]) ; if(A[i] == t) ans.push_back(1) ; else ans.push_back(0) ; } return ans ; }
#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...