Submission #149477

#TimeUsernameProblemLanguageResultExecution timeMemory
149477갓띵건 (#200)Bulb Game (FXCUP4_bulb)C++17
0 / 100
2 ms400 KiB
#include "bulb.h" #include<bits/stdc++.h> using namespace std; #define fast ios::sync_with_stdio(false);cin.tie(0) #define fi first #define se second #define eb emplace_back #define pb push_back #define all(v) (v).begin(), (v).end() #define pre(a) cout<<fixed;cout.precision(a) typedef long long ll; typedef pair<int,int> pii; typedef pair<ll, ll> pll; const int inf = 1e9; const ll INF = 1e18; int n; vector<int> l, r; int change[300010]; int dfs(int x) { if(x < 0) return x; dfs(l[x]); dfs(r[x]); change[x] = inf; if(l[x] == -1) { change[x] = 0; } if(r[x] == -1) { change[x] = min(change[x], 1); } if(l[x] >= 0) { change[x] = min(change[x], change[l[x]]); } if(r[x] >= 0) { change[x] = min(change[x], change[r[x]]+1); } //cout << "!" << x << " " << change[x] <<endl; } int FindWinner(int T, std::vector<int> L, std::vector<int> R){ n = L.size(); l = L; r = R; dfs(0); for(int i=0; i<n; i++) { //cout << change[i] << endl; } int cnt = 0; if(change[0] != 0) return 0; for(int i=0; i>=0; i = l[i]) { if(r[i] == -2) return 0; if(r[i] == -1) continue; if(change[r[i]] >= inf) return 0; cnt += change[r[i]]; cnt = min(cnt, inf); //cout << "!" << r[i] << " " << change[r[i]] << endl; } if(cnt <= 1) return 1; else return 0; }

Compilation message (stderr)

bulb.cpp: In function 'int dfs(int)':
bulb.cpp:45:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...