# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
149852 |
2019-09-01T07:16:59 Z |
graneli(#3789, toloraia) |
Bulb Game (FXCUP4_bulb) |
C++17 |
|
2 ms |
376 KB |
#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
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 time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |