Submission #149852

#TimeUsernameProblemLanguageResultExecution timeMemory
149852graneli (#200)Bulb Game (FXCUP4_bulb)C++17
0 / 100
2 ms376 KiB
#include "bulb.h" #include <bits/stdc++.h> #define F first #define S second #define mp make_pair #define pb push_back //#define ll __int128 #define ll long long #define LEFT(a) ((a)<<1) #define RIGHT(a) (LEFT(a) + 1) #define MID(a,b) ((a+b)>>1) #define MAX(a,b) ((a)>(b)?(a):(b)) #define MIN(a,b) ((a)<(b)?(a):(b)) #define y1 y122 using namespace std; const int N = 1000005; int n; int L[N], R[N]; bool F[N]; int l, r; int T; int in[N], out[N]; bool OK; void dfs (int k, int A, int B, int dist){ if (k < 0){ if (k == -1) return; if (A == -1 && B == -1){ OK = 1; return; } if (A != -1 && B != -1){ F[A] = 0; F[B] = 0; return; } ++T; l = min (l, T); r = max (r, T); if (dist != n) F[A] = 0; return; } in[k] = ++T; dfs (L[k], A, B, dist + 1); if (B == -1){ if (A == -1) A = k; else B = k; dfs (R[k], A, B, dist + 1); } out[k] = ++T; } int FindWinner(int titu, std::vector<int> aaaa, std::vector<int> bbbb){ n = aaaa.size(); for (int i = 0; i < n; i++){ L[i] = aaaa[i]; R[i] = bbbb[i]; F[i] = 1; } l = N * 5; r = -10; dfs (0, -1, -1, 0); if (OK) return 0; for (int i = 0; i < n; i++) if (in[i] <= l && r <= out[i] && F[i] == 1){ cout << i << endl; return 1; } return 0; }

Compilation message (stderr)

bulb.cpp: In function 'int FindWinner(int, std::vector<int>, std::vector<int>)':
bulb.cpp:74:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
     for (int i = 0; i < n; i++)
     ^~~
bulb.cpp:79:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
  return 0;
  ^~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...