#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;
}
ll decode(ll x,ll y)
{
ll i,s=0;
for(i=y;i>=x;i--)
{
s=s*2+v[i];
}
return s;
}
void Fill(ll x,ll y,ll 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 |
10 ms |
2348 KB |
Output is correct |
2 |
Correct |
9 ms |
2356 KB |
Output is correct |
3 |
Correct |
10 ms |
2348 KB |
Output is correct |
4 |
Correct |
10 ms |
2348 KB |
Output is correct |
5 |
Correct |
11 ms |
2364 KB |
Output is correct |
6 |
Correct |
10 ms |
2464 KB |
Output is correct |
7 |
Correct |
9 ms |
2360 KB |
Output is correct |
8 |
Correct |
10 ms |
2348 KB |
Output is correct |
9 |
Correct |
10 ms |
2356 KB |
Output is correct |
10 |
Correct |
10 ms |
2356 KB |
Output is correct |
11 |
Correct |
10 ms |
2340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
39 ms |
8960 KB |
Wrong Answer [6] |
2 |
Halted |
0 ms |
0 KB |
- |