#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;
int gol[N],gor[N];
int dfs(int u) {
if (u<0) return u;
else {
gol[u]=dfs(l[u]);
gor[u]=dfs(r[u]);
return gol[u];
}
}
int FindWinner(int T, std::vector<int> L, std::vector<int> R){
l=L; r=R;
n=L.size();
auto check=[&] () {
dfs(0);
int p=0;
int cnt=0;
while (p>=0) {
if (gor[p]==-2) return 0;
p=l[p];
cnt++;
}
if (gol[0]==-2&&cnt!=n) return 0;
return 1;
};
dfs(0);
if (gol[0]==-2) return 0;
for (int p=0;p<n;p++) {
swap(l[p],r[p]);
if (check()) return 1;
swap(l[p],r[p]);
}
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 |
10 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 |
10 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
3 ms |
348 KB |
Output is correct |
9 |
Correct |
10 ms |
348 KB |
Output is correct |
10 |
Correct |
10 ms |
376 KB |
Output is correct |
11 |
Correct |
5 ms |
376 KB |
Output is correct |
12 |
Correct |
2 ms |
348 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 |
10 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 |
10 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
3 ms |
348 KB |
Output is correct |
11 |
Correct |
10 ms |
348 KB |
Output is correct |
12 |
Correct |
10 ms |
376 KB |
Output is correct |
13 |
Correct |
5 ms |
376 KB |
Output is correct |
14 |
Correct |
2 ms |
348 KB |
Output is correct |
15 |
Correct |
2 ms |
368 KB |
Output is correct |
16 |
Correct |
2 ms |
376 KB |
Output is correct |
17 |
Correct |
4 ms |
376 KB |
Output is correct |
18 |
Correct |
2 ms |
452 KB |
Output is correct |
19 |
Correct |
2 ms |
376 KB |
Output is correct |
20 |
Correct |
9 ms |
408 KB |
Output is correct |
21 |
Correct |
10 ms |
408 KB |
Output is correct |
22 |
Correct |
7 ms |
376 KB |
Output is correct |
23 |
Correct |
10 ms |
412 KB |
Output is correct |
24 |
Correct |
10 ms |
376 KB |
Output is correct |
25 |
Correct |
8 ms |
440 KB |
Output is correct |
26 |
Correct |
2 ms |
296 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 |
10 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 |
10 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
3 ms |
348 KB |
Output is correct |
11 |
Correct |
10 ms |
348 KB |
Output is correct |
12 |
Correct |
10 ms |
376 KB |
Output is correct |
13 |
Correct |
5 ms |
376 KB |
Output is correct |
14 |
Correct |
2 ms |
348 KB |
Output is correct |
15 |
Correct |
2 ms |
368 KB |
Output is correct |
16 |
Correct |
2 ms |
376 KB |
Output is correct |
17 |
Correct |
4 ms |
376 KB |
Output is correct |
18 |
Correct |
2 ms |
452 KB |
Output is correct |
19 |
Correct |
2 ms |
376 KB |
Output is correct |
20 |
Correct |
9 ms |
408 KB |
Output is correct |
21 |
Correct |
10 ms |
408 KB |
Output is correct |
22 |
Correct |
7 ms |
376 KB |
Output is correct |
23 |
Correct |
10 ms |
412 KB |
Output is correct |
24 |
Correct |
10 ms |
376 KB |
Output is correct |
25 |
Correct |
8 ms |
440 KB |
Output is correct |
26 |
Correct |
2 ms |
296 KB |
Output is correct |
27 |
Correct |
86 ms |
11796 KB |
Output is correct |
28 |
Correct |
110 ms |
12576 KB |
Output is correct |
29 |
Execution timed out |
1055 ms |
12160 KB |
Time limit exceeded |
30 |
Halted |
0 ms |
0 KB |
- |