#include "Anna.h"
#include "Bruno.h"
#include <vector>
#include <algorithm>
using namespace std;
#define F1 63
#define F2 44
vector<int> a;
long long fib[65];
void Anna(int N, std::vector<char> S)
{
int i;
fib[0] = 1;
fib[1]=2;
for (i = 2; i <= F1; i++)
{
fib[i] = fib[i - 1] + fib[i - 2];
}
int xh = 0;
for (i = 0; i < N; i++)
{
if (!xh && S[i] == 'X')
{
xh = 1;
a.push_back(1);
a.push_back(0);
}
else if (xh)
{
a.push_back((S[i] == 'Z' && (i + 1 == N || S[i + 1] != 'Z')));
}
else
a.push_back(0);
}
for (; a.size() % F1;)
{
a.push_back(0);
}
for (i = 0; i < a.size(); i += F1)
{
int j;
long long ans = 0;
for (j = i + F1 - 1; j >= i; j--)
{
if (a[j] == 1)
{
ans += fib[(i + F1 - 1) - j];
}
}
for (j = 0; j < F2; j++)
{
Send((ans >> j) & 1);
}
}
}
#include "Anna.h"
#include "Bruno.h"
#include <vector>
#include <algorithm>
using namespace std;
#define F1 63
#define F2 44
vector<int> a;
long long fib[65];
void Bruno(int N, int L, std::vector<int> A)
{
int i;
fib[0] = 1;
fib[1] = 2;
for (i = 2; i <= F1; i++)
{
fib[i] = fib[i - 1] + fib[i - 2];
}
vector<int>t;
for (i = 0; i < L; i+=F2)
{
long long cu = 0;
int j;
for (j = i; j < i+F2; j++)
{
cu += (long long)A[j] << ((long long)(j - i));
}
for (j = F1 - 1; j >= 0; j--)
{
if (fib[j] <= cu)
{
cu -= fib[j];
t.push_back(1);
}
else
{
t.push_back(0);
}
}
}
for (i = 0; i < N; i++)
{
if (t[i] == 1)
{
break;
}
Remove(i);
}
int finalrm = i;
i+=2;
int la = i-1;
for (; i < N+1; i++)
{
if (t[i])
{
int j;
for (j = i - 1; j > la; j--)
Remove(j-1);
Remove(i-1);
la = i;
}
}
i = min(i, N + 1);
int j;
for (j = i - 1; j > la; j--)
Remove(j - 1);
if (finalrm < N)
Remove(finalrm);
}
Compilation message
Anna.cpp: In function 'void Anna(int, std::vector<char>)':
Anna.cpp:39:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
39 | for (i = 0; i < a.size(); i += F1)
| ~~^~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
516 KB |
Output is correct |
2 |
Correct |
0 ms |
516 KB |
Output is correct |
3 |
Correct |
0 ms |
516 KB |
Output is correct |
4 |
Correct |
0 ms |
520 KB |
Output is correct |
5 |
Correct |
0 ms |
516 KB |
Output is correct |
6 |
Correct |
0 ms |
516 KB |
Output is correct |
7 |
Correct |
0 ms |
516 KB |
Output is correct |
8 |
Correct |
1 ms |
508 KB |
Output is correct |
9 |
Correct |
1 ms |
516 KB |
Output is correct |
10 |
Correct |
0 ms |
508 KB |
Output is correct |
11 |
Correct |
0 ms |
508 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
53 ms |
8120 KB |
Output is correct |
2 |
Correct |
52 ms |
8164 KB |
Output is correct |
3 |
Correct |
59 ms |
8076 KB |
Output is correct |
4 |
Correct |
56 ms |
8468 KB |
Output is correct |
5 |
Correct |
52 ms |
8420 KB |
Output is correct |
6 |
Correct |
55 ms |
8460 KB |
Output is correct |
7 |
Correct |
49 ms |
8436 KB |
Output is correct |
8 |
Correct |
71 ms |
8300 KB |
Output is correct |
9 |
Correct |
63 ms |
8320 KB |
Output is correct |
10 |
Correct |
53 ms |
8440 KB |
Output is correct |
11 |
Correct |
53 ms |
8392 KB |
Output is correct |
12 |
Correct |
55 ms |
8308 KB |
Output is correct |
13 |
Correct |
63 ms |
8344 KB |
Output is correct |
14 |
Correct |
56 ms |
8416 KB |
Output is correct |
15 |
Correct |
64 ms |
8384 KB |
Output is correct |
16 |
Correct |
61 ms |
8340 KB |
Output is correct |
17 |
Correct |
64 ms |
8304 KB |
Output is correct |
18 |
Correct |
56 ms |
8316 KB |
Output is correct |
19 |
Correct |
60 ms |
8396 KB |
Output is correct |
20 |
Correct |
57 ms |
8348 KB |
Output is correct |
21 |
Correct |
49 ms |
8416 KB |
Output is correct |
22 |
Correct |
59 ms |
8388 KB |
Output is correct |
23 |
Correct |
53 ms |
8304 KB |
Output is correct |
24 |
Correct |
55 ms |
8392 KB |
Output is correct |
25 |
Correct |
57 ms |
8332 KB |
Output is correct |
26 |
Correct |
61 ms |
8352 KB |
Output is correct |
27 |
Correct |
56 ms |
8328 KB |
Output is correct |
28 |
Correct |
74 ms |
8468 KB |
Output is correct |
29 |
Correct |
62 ms |
8380 KB |
Output is correct |
30 |
Correct |
56 ms |
8332 KB |
Output is correct |
31 |
Correct |
60 ms |
8408 KB |
Output is correct |
32 |
Correct |
63 ms |
8312 KB |
Output is correct |
33 |
Correct |
50 ms |
8356 KB |
Output is correct |