Submission #148146

# Submission time Handle Problem Language Result Execution time Memory
148146 2019-08-31T14:49:52 Z 조팍시\n123(#3740, tlwpdus, ainta, cki86201) Bulb Game (FXCUP4_bulb) C++17
100 / 100
106 ms 10388 KB
#include "bulb.h"
#include <bits/stdc++.h>

using namespace std;

int n;

vector<int> L, R;

int isgood(int p, int c) {
    if (p<0) return p==-1||c==n+1;
    int t = R[p];
    while(t>=0) {
        t = L[t];
    }
    if (t==-2) return 0;
    return isgood(L[p],c+1);
}

int nope[300100];
int FindWinner(int T, std::vector<int> l, std::vector<int> r){
    L.assign(l.begin(),l.end());
    R.assign(r.begin(),r.end());
	n = L.size();

	int p = 0;
	while(p>=0) {
        p = L[p];
	}
	if (p==-2) return 0;
	p = 0;
	int c = 0;
	while(p>=0) {
	    c++;
	    nope[p] = 1;
        if (isgood(R[p],c+1)) return 1;
        int q = R[p];
        while(q>=0) {
            int t = R[q];
            while(t>=0) {
                t=L[t];
            }
            if (t==-2) nope[q] = 1;
            q = L[q];
        }
        if (q==-2) return 0;
        p = L[p];
	}
	for (int i=0;i<n;i++) if (!nope[i]) return 1;

	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 380 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 380 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 420 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 348 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 380 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 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 380 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 420 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 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 292 KB Output is correct
20 Correct 2 ms 404 KB Output is correct
21 Correct 2 ms 388 KB Output is correct
22 Correct 2 ms 348 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 3 ms 376 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 348 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 380 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 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 380 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 420 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 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 292 KB Output is correct
20 Correct 2 ms 404 KB Output is correct
21 Correct 2 ms 388 KB Output is correct
22 Correct 2 ms 348 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 3 ms 376 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 74 ms 10136 KB Output is correct
28 Correct 74 ms 10324 KB Output is correct
29 Correct 74 ms 9976 KB Output is correct
30 Correct 105 ms 10244 KB Output is correct
31 Correct 72 ms 10232 KB Output is correct
32 Correct 74 ms 8224 KB Output is correct
33 Correct 74 ms 10388 KB Output is correct
34 Correct 74 ms 10272 KB Output is correct
35 Correct 74 ms 10272 KB Output is correct
36 Correct 74 ms 10288 KB Output is correct
37 Correct 74 ms 10264 KB Output is correct
38 Correct 74 ms 10008 KB Output is correct
39 Correct 73 ms 10272 KB Output is correct
40 Correct 75 ms 10332 KB Output is correct
41 Correct 106 ms 8600 KB Output is correct
42 Correct 74 ms 10288 KB Output is correct
43 Correct 74 ms 10204 KB Output is correct
44 Correct 74 ms 9896 KB Output is correct
45 Correct 74 ms 9168 KB Output is correct
46 Correct 74 ms 10132 KB Output is correct
47 Correct 75 ms 8996 KB Output is correct
48 Correct 74 ms 9080 KB Output is correct
49 Correct 75 ms 10040 KB Output is correct
50 Correct 73 ms 7416 KB Output is correct