Submission #149393

# Submission time Handle Problem Language Result Execution time Memory
149393 2019-09-01T06:23:38 Z 还没编好(#3801, cauchysheep, fjzzq2002, apiad) Bulb Game (FXCUP4_bulb) C++17
100 / 100
154 ms 48376 KB
#include "bulb.h"
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head

const int N=301000;
VI l,r;
int n,fg,saf[N],tsaf,vis[N];

void dfs(int u,int par,int dep,VI pt) {
	if (SZ(pt)>2) return;
	if (u<0) {
		if (u!=-2) return;
		if (SZ(pt)==0) {
			fg=1;
		} else if (SZ(pt)==2) {
			vis[pt[0]]=1; vis[pt[1]]=1;
		} else {
			if (dep==n) return;
			vis[pt[0]]=1;
			saf[par]++;
			tsaf++;
		}
	} else {
		dfs(l[u],u,dep+1,pt);
		pt.pb(u);
		dfs(r[u],u,dep+1,pt);
		if (l[u]>=0) saf[u]+=saf[l[u]];
		if (r[u]>=0) saf[u]+=saf[r[u]];
	}
}

int FindWinner(int T, std::vector<int> L, std::vector<int> R){
	l=L; r=R;
	n=L.size();
	dfs(0,0,0,VI(0));
	if (fg) return 0;
	rep(i,0,n) if (!vis[i]&&saf[i]==tsaf) return 1;
	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 380 KB Output is correct
4 Correct 2 ms 480 KB Output is correct
5 Correct 3 ms 504 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 376 KB Output is correct
9 Correct 2 ms 348 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 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 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 380 KB Output is correct
6 Correct 2 ms 480 KB Output is correct
7 Correct 3 ms 504 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 376 KB Output is correct
11 Correct 2 ms 348 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 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 504 KB Output is correct
19 Correct 3 ms 504 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 372 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 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 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 380 KB Output is correct
6 Correct 2 ms 480 KB Output is correct
7 Correct 3 ms 504 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 376 KB Output is correct
11 Correct 2 ms 348 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 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 504 KB Output is correct
19 Correct 3 ms 504 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 372 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 376 KB Output is correct
27 Correct 73 ms 9128 KB Output is correct
28 Correct 72 ms 8028 KB Output is correct
29 Correct 73 ms 8824 KB Output is correct
30 Correct 147 ms 48376 KB Output is correct
31 Correct 154 ms 48092 KB Output is correct
32 Correct 76 ms 7848 KB Output is correct
33 Correct 73 ms 7928 KB Output is correct
34 Correct 73 ms 7856 KB Output is correct
35 Correct 73 ms 7844 KB Output is correct
36 Correct 74 ms 7876 KB Output is correct
37 Correct 74 ms 8492 KB Output is correct
38 Correct 73 ms 8484 KB Output is correct
39 Correct 73 ms 8568 KB Output is correct
40 Correct 73 ms 8232 KB Output is correct
41 Correct 75 ms 8484 KB Output is correct
42 Correct 74 ms 8484 KB Output is correct
43 Correct 74 ms 8308 KB Output is correct
44 Correct 74 ms 8216 KB Output is correct
45 Correct 74 ms 8284 KB Output is correct
46 Correct 73 ms 8028 KB Output is correct
47 Correct 139 ms 18408 KB Output is correct
48 Correct 130 ms 18024 KB Output is correct
49 Correct 131 ms 18092 KB Output is correct
50 Correct 127 ms 18100 KB Output is correct