#include "Anna.h"
#include<bits/stdc++.h>
using namespace std;
typedef int ll;
typedef long long int lll;
long long int fibb[1100];
void Send_X(ll x)
{
ll i;
for(i=0;i<20;i++)
{
Send(x%2);
x/=2;
}
}
void sans(vector<ll> v)
{
ll i;
long long int s=0;
for(i=0;i<63;i++)
{
s+=lll(v[i])*fibb[i];
}
for(i=0;i<44;i++)
{
Send(s%2);
s/=2;
}
}
ll a[220000];
vector<ll> fib;
void Anna(ll N,vector<char> S) {
fibb[0]=1;
fibb[1]=2;
ll i,j;
for(i=2;i<=63;i++)
{
fibb[i]=fibb[i-1]+fibb[i-2];
}
ll n,x=0,z=N+1;
n=N;
for(i=n-1;i>=0;i--)
{
if(S[i]=='X')
{
x=i;
}
}
for(i=0;i<n;i++)
{
if(S[i]=='Z')
z=i;
}
for(i=0;i<n;i++)
{
if(i==n&&S[i]=='Z')
{
a[i]=1;
}
if(i<n)
{
if(S[i]=='Z'&&S[i+1]!='Z')
{
a[i]=1;
}
}
}
Send_X(x);
for(i=0;i<100000;i+=63)
{
fib.clear();
for(j=i;j<i+63;j++)
{
fib.push_back(a[j]);
}
/*if(i==0)
{
for(j=0;j<63;j++)
printf("%lld ",fib[j]);
printf("\n");
}
*/
sans(fib);
}
return;
}
#include "Bruno.h"
#include<bits/stdc++.h>
using namespace std;
typedef int ll;
typedef long long int lll;
vector<ll> v;
deque<ll> stk;
ll b[220000];
long long int fibbb[1100];
ll inv_X()
{
ll i;
ll s=0;
for(i=19;i>=0;i--)
{
// printf("%d,",v[i]);
s=s*2+v[i];
}
return s;
}
lll decode(ll x,ll y)
{
lll i,s=0;
for(i=y;i>=x;i--)
{
s=s*2+v[i];
}
return s;
}
void Fill(ll x,ll y,long long int z)
{
long long int s=z;
ll i;
for(i=y;i>=x;i--)
{
if(s>=fibbb[62-y+i])
{b[i]=1;
s-=fibbb[62-y+i];
}
}
}
void Bruno(int N, int L,vector<int> A) {
fibbb[0]=1;
fibbb[1]=2;
ll i;
for(i=2;i<=63;i++)
{
fibbb[i]=fibbb[i-1]+fibbb[i-2];
}
lll t=0;
ll n,j,x,y,z;
// printf("[%d]\n",L);
n=N;
v.clear();
v.resize(L);
for(i=0;i<L;i++)
v[i]=A[i];
z=inv_X();
x=z;
//printf("%d\n",y);
//b[y]=1;
// printf("%d\n",z);
for(i=0;i<x;i++)
Remove(i);
i=20;
j=0;
while(1)
{
if(j>=n)
break;
t=decode(i,i+43);
/* if(i==20)
printf("%lld\n",t);
*/ Fill(j,j+62,t);
i+=44;
j+=63;
}
//stk.push_back(x);
for(i=z;i<n;i++)
{
//printf("%d\n",i);
if(b[i]==0)
{
stk.push_back(i);
continue;
}
else
{
while(stk.size()>=2)
{
x=stk.back();
Remove(x);
stk.pop_back();
}
Remove(i);
continue;
}
}
/* printf("\n");
for(i=0;i<n;i++)
printf("%d ",b[i]);
printf("\n");
*/while(stk.size()>=1)
{
x=stk.back();
//printf("%d\n",x);
Remove(x);
stk.pop_back();
}
}
Compilation message
Anna.cpp: In function 'void Anna(ll, std::vector<char>)':
Anna.cpp:41:14: warning: variable 'z' set but not used [-Wunused-but-set-variable]
41 | ll n,x=0,z=N+1;
| ^
Bruno.cpp: In function 'void Bruno(int, int, std::vector<int>)':
Bruno.cpp:51:14: warning: unused variable 'y' [-Wunused-variable]
51 | ll n,j,x,y,z;
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
2344 KB |
Output is correct |
2 |
Correct |
10 ms |
2348 KB |
Output is correct |
3 |
Correct |
10 ms |
2340 KB |
Output is correct |
4 |
Correct |
12 ms |
2768 KB |
Output is correct |
5 |
Correct |
10 ms |
2356 KB |
Output is correct |
6 |
Correct |
10 ms |
2344 KB |
Output is correct |
7 |
Correct |
10 ms |
2324 KB |
Output is correct |
8 |
Correct |
9 ms |
2344 KB |
Output is correct |
9 |
Correct |
10 ms |
2360 KB |
Output is correct |
10 |
Correct |
9 ms |
2348 KB |
Output is correct |
11 |
Correct |
9 ms |
2344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
39 ms |
9072 KB |
Output is correct |
2 |
Correct |
39 ms |
9196 KB |
Output is correct |
3 |
Correct |
39 ms |
9044 KB |
Output is correct |
4 |
Correct |
41 ms |
8960 KB |
Output is correct |
5 |
Correct |
38 ms |
8972 KB |
Output is correct |
6 |
Correct |
38 ms |
9004 KB |
Output is correct |
7 |
Correct |
39 ms |
9084 KB |
Output is correct |
8 |
Correct |
37 ms |
9016 KB |
Output is correct |
9 |
Correct |
43 ms |
8952 KB |
Output is correct |
10 |
Correct |
38 ms |
9720 KB |
Output is correct |
11 |
Correct |
40 ms |
8932 KB |
Output is correct |
12 |
Correct |
41 ms |
9016 KB |
Output is correct |
13 |
Correct |
41 ms |
8372 KB |
Output is correct |
14 |
Correct |
43 ms |
8964 KB |
Output is correct |
15 |
Correct |
40 ms |
9032 KB |
Output is correct |
16 |
Correct |
43 ms |
8924 KB |
Output is correct |
17 |
Correct |
37 ms |
8280 KB |
Output is correct |
18 |
Correct |
37 ms |
8248 KB |
Output is correct |
19 |
Correct |
36 ms |
8204 KB |
Output is correct |
20 |
Correct |
37 ms |
9068 KB |
Output is correct |
21 |
Correct |
37 ms |
8996 KB |
Output is correct |
22 |
Correct |
45 ms |
8420 KB |
Output is correct |
23 |
Correct |
37 ms |
8988 KB |
Output is correct |
24 |
Correct |
37 ms |
9100 KB |
Output is correct |
25 |
Correct |
36 ms |
8348 KB |
Output is correct |
26 |
Correct |
38 ms |
8368 KB |
Output is correct |
27 |
Correct |
43 ms |
8436 KB |
Output is correct |
28 |
Correct |
36 ms |
8448 KB |
Output is correct |
29 |
Correct |
36 ms |
8148 KB |
Output is correct |
30 |
Correct |
41 ms |
8444 KB |
Output is correct |
31 |
Correct |
38 ms |
8168 KB |
Output is correct |
32 |
Correct |
38 ms |
8948 KB |
Output is correct |
33 |
Correct |
38 ms |
9120 KB |
Output is correct |