Submission #151085

#TimeUsernameProblemLanguageResultExecution timeMemory
151085kuroniBulb Game (FXCUP4_bulb)C++17
100 / 100
76 ms6672 KiB
#include "bulb.h" #include <cstdio> using namespace std; int dive(int u, vector<int> &l) { while (u >= 0) u = l[u]; return u == -1; } int FindWinner(int t, vector<int> l, vector<int> r) { int n = l.size(); if (!dive(0, l)) return 0; for (int u = 0; u >= 0; u = l[u]) if (!dive(r[u], l)) { bool ok1 = false, ok2 = true; for (int v = 0; v != l[u] && !ok1; v = l[v]) { bool cur = true; for (int k = r[v]; k >= 0; k = l[k]) if (!dive(r[k], l)) { cur = false; break; } ok1 |= cur; } if (r[u] >= 0) { swap(l[r[u]], r[r[u]]); for (int v = 0; v >= 0; v = l[v]) if (!dive(r[v], l)) { ok2 = false; break; } swap(l[r[u]], r[r[u]]); } else ok2 = false; return ok1 || ok2; } return 1; }

Compilation message (stderr)

bulb.cpp: In function 'int FindWinner(int, std::vector<int>, std::vector<int>)':
bulb.cpp:14:6: warning: unused variable 'n' [-Wunused-variable]
  int n = l.size();
      ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...