Submission #149862

# Submission time Handle Problem Language Result Execution time Memory
149862 2019-09-01T07:18:04 Z graneli(#3789, toloraia) Bulb Game (FXCUP4_bulb) C++17
100 / 100
104 ms 24096 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)
            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:77: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 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 504 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 348 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 380 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 504 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 348 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 380 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 440 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 2 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 504 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 348 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 380 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 440 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 2 ms 348 KB Output is correct
27 Correct 74 ms 8612 KB Output is correct
28 Correct 74 ms 8488 KB Output is correct
29 Correct 74 ms 8232 KB Output is correct
30 Correct 103 ms 24096 KB Output is correct
31 Correct 104 ms 24080 KB Output is correct
32 Correct 77 ms 8348 KB Output is correct
33 Correct 75 ms 8492 KB Output is correct
34 Correct 75 ms 8452 KB Output is correct
35 Correct 74 ms 8352 KB Output is correct
36 Correct 75 ms 8440 KB Output is correct
37 Correct 75 ms 8296 KB Output is correct
38 Correct 74 ms 8344 KB Output is correct
39 Correct 74 ms 8608 KB Output is correct
40 Correct 73 ms 8440 KB Output is correct
41 Correct 74 ms 8568 KB Output is correct
42 Correct 74 ms 8356 KB Output is correct
43 Correct 75 ms 8228 KB Output is correct
44 Correct 74 ms 8412 KB Output is correct
45 Correct 74 ms 8476 KB Output is correct
46 Correct 74 ms 8484 KB Output is correct
47 Correct 92 ms 13232 KB Output is correct
48 Correct 92 ms 13176 KB Output is correct
49 Correct 93 ms 13220 KB Output is correct
50 Correct 91 ms 13176 KB Output is correct