#include "Annalib.h"
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
bool b[160],d[160];
bool used[160];
void Anna(int N,ll X,int K,int P[]){
static mt19937 mt(314159);
uniform_int_distribution<>dist(0,N-1);
memset(b,0,sizeof(b));
memset(d,0,sizeof(d));
memset(used,0,sizeof(used));
rep(i,K){
b[P[i]]=1;
}
rep(loop,N/2){
int i,j;
do{
i=dist(mt);
j=dist(mt);
}while(i==j||used[i]||used[j]);
used[i]=used[j]=true;
int e=X%3;
if((e==0&&!b[j])||(e==1&&!b[i])||(e==2&&!b[i]&&!b[j])){
if(e==0)d[i]=0,d[j]=1;
if(e==1)d[i]=1,d[j]=0;
if(e==2)d[i]=1,d[j]=1;
X/=3;
}
}
rep(i,N)Set(i,d[i]);
}
#include "Brunolib.h"
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
ll Bruno(int N,int A[]){
static mt19937 mt(314159);
uniform_int_distribution<>dist(0,N-1);
bool used[160]{};
ll ans=0,x=1;
rep(loop,N/2){
int i,j;
do{
i=dist(mt);
j=dist(mt);
}while(i==j||used[i]||used[j]);
used[i]=used[j]=true;
if(A[i]||A[j]){
ans+=(A[i]*2+A[j]-1)*x;
x*=3;
}
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1460 ms |
3264 KB |
Output is correct - L* = 40 |
2 |
Correct |
1460 ms |
2992 KB |
Output is correct - L* = 40 |
3 |
Correct |
1460 ms |
3056 KB |
Output is correct - L* = 40 |
4 |
Correct |
1456 ms |
3056 KB |
Output is correct - L* = 40 |
5 |
Correct |
1456 ms |
3208 KB |
Output is correct - L* = 40 |
6 |
Correct |
1460 ms |
3440 KB |
Output is correct - L* = 40 |
7 |
Correct |
1459 ms |
3056 KB |
Output is correct - L* = 40 |
8 |
Correct |
1456 ms |
3264 KB |
Output is correct - L* = 40 |
9 |
Correct |
1451 ms |
3312 KB |
Output is correct - L* = 40 |
10 |
Correct |
1451 ms |
3056 KB |
Output is correct - L* = 40 |
11 |
Correct |
1460 ms |
3128 KB |
Output is correct - L* = 40 |
12 |
Correct |
1448 ms |
3312 KB |
Output is correct - L* = 40 |
13 |
Correct |
1452 ms |
3016 KB |
Output is correct - L* = 40 |
14 |
Correct |
1467 ms |
3096 KB |
Output is correct - L* = 40 |
15 |
Correct |
1460 ms |
3312 KB |
Output is correct - L* = 40 |
16 |
Correct |
1452 ms |
3056 KB |
Output is correct - L* = 40 |
17 |
Correct |
1475 ms |
3536 KB |
Output is correct - L* = 40 |
18 |
Correct |
1463 ms |
3312 KB |
Output is correct - L* = 40 |
19 |
Correct |
1456 ms |
3056 KB |
Output is correct - L* = 40 |
20 |
Correct |
1476 ms |
3352 KB |
Output is correct - L* = 40 |
21 |
Correct |
1460 ms |
3056 KB |
Output is correct - L* = 40 |
22 |
Correct |
1456 ms |
3056 KB |
Output is correct - L* = 40 |
23 |
Correct |
1446 ms |
3568 KB |
Output is correct - L* = 40 |
24 |
Correct |
1454 ms |
3312 KB |
Output is correct - L* = 40 |
25 |
Correct |
1448 ms |
3312 KB |
Output is correct - L* = 40 |
26 |
Correct |
1455 ms |
3056 KB |
Output is correct - L* = 40 |
27 |
Correct |
1456 ms |
3056 KB |
Output is correct - L* = 40 |
28 |
Correct |
1456 ms |
3224 KB |
Output is correct - L* = 40 |
29 |
Correct |
1450 ms |
3336 KB |
Output is correct - L* = 40 |
30 |
Correct |
1448 ms |
3056 KB |
Output is correct - L* = 40 |
31 |
Correct |
1459 ms |
3056 KB |
Output is correct - L* = 40 |
32 |
Correct |
1458 ms |
3184 KB |
Output is correct - L* = 40 |
33 |
Correct |
1460 ms |
3568 KB |
Output is correct - L* = 40 |
34 |
Correct |
1455 ms |
3056 KB |
Output is correct - L* = 40 |
35 |
Correct |
1478 ms |
3056 KB |
Output is correct - L* = 40 |
36 |
Correct |
1466 ms |
3312 KB |
Output is correct - L* = 40 |
37 |
Correct |
1458 ms |
3312 KB |
Output is correct - L* = 40 |
38 |
Correct |
1458 ms |
3056 KB |
Output is correct - L* = 40 |
39 |
Correct |
1456 ms |
3056 KB |
Output is correct - L* = 40 |
40 |
Correct |
1455 ms |
3064 KB |
Output is correct - L* = 40 |