#include "Anna.h"
#include <bits/stdc++.h>
#define pii pair<int, int>
#define ff first
#define ss second
using namespace std;
namespace
{
}
void Anna(int N, vector<char> S)
{
int start = -1, last = -1;
for(int i = 0; i < N; ++i)
{
if(start == -1 && S[i] == 'X') start = i;
if(S[i] == 'Z') last = i;
}
vector<int> R;
if(start == -1 || last == -1 || start > last)
{
Send(0);
return;
}
Send(1);
for(int i = 0; i < 14; ++i) Send(start >> i & 1);
for(int i = 0; i < 14; ++i) Send(last >> i & 1);
for(int i = start + 1; i < last; ++i)
{
if(S[i] == 'X' && S[i - 1] == 'Y') R.push_back(1);
else if(S[i] == 'Y' && S[i + 1] == 'X') R.push_back(1);
else R.push_back(0);
}
for(int i = last + 1; i < N; ++i) R.push_back(0);
vector<int> Q{0, 0};
int pt = 0;
while(pt < (int)R.size())
{
if(R[pt] == 0) Q.push_back(0), ++pt;
if(R[pt] == 1) Q.push_back(1), pt += 2;
}
vector<int> T{0, 1};
pt = 0;
while(pt < (int)R.size())
{
if(R[pt] == 0)
{
if(pt + 1 < (int)R.size() && R[pt + 1] == 0) T.push_back(0), pt += 2;
else T.push_back(1), T.push_back(0), pt += 3;
}
else T.push_back(1), T.push_back(1), pt += 2;
}
if(T.size() < Q.size()) swap(T, Q);
T = {1, 0};
pt = 0;
while(pt < (int)R.size())
{
if(R[pt] == 1)
{
if(pt + 2 < (int)R.size() && R[pt + 2] == 0) T.push_back(0), pt += 3;
else T.push_back(1), T.push_back(1), pt += 4;
}
else T.push_back(1), T.push_back(0), ++pt;
}
if(T.size() < Q.size()) swap(T, Q);
T = {1, 1};
pt = 0;
while(pt < (int)R.size())
{
if(R[pt] == 1)
{
if(pt + 2 < (int)R.size() && R[pt + 2] == 0) T.push_back(1), T.push_back(0), pt += 3;
else T.push_back(1), T.push_back(1), pt += 4;
}
else T.push_back(0), ++pt;
}
if(T.size() < Q.size()) swap(T, Q);
for(auto i : Q) Send(i);
}
#include "Bruno.h"
#include <bits/stdc++.h>
using namespace std;
namespace
{
}
void Bruno(int N, int L, vector<int> A)
{
if(A[0] == 0)
{
for(int i = 0; i < N; ++i) Remove(i);
return;
}
int start = 0, last = 0;
for(int i = 0; i < 14; ++i) if(A[i + 1]) start += 1 << i;
for(int i = 0; i < 14; ++i) if(A[i + 15]) last += 1 << i;
vector<int> B;
for(int i = 0; i < start; ++i) B.push_back(0);
B.push_back(1);
if(A[29] == 0 && A[30] == 1)
{
for(int i = 31; i < (int)A.size(); ++i)
{
if(A[i] == 0) B.push_back(0);
else B.push_back(1), B.push_back(1);
}
}
else if(A[29] == 0 && A[30] == 1)
{
for(int i = 31; i < (int)A.size(); ++i)
{
if(A[i] == 0) B.push_back(0), B.push_back(0);
else if(A[i + 1] == 0) B.push_back(0), B.push_back(1), B.push_back(1);
else B.push_back(1), B.push_back(1);
}
}
else if(A[29] == 1 && A[30] == 0)
{
for(int i = 31; i < (int)A.size(); ++i)
{
if(A[i] == 0) B.push_back(1), B.push_back(1), B.push_back(0);
else if(A[i + 1] == 0) B.push_back(0);
else B.push_back(1), B.push_back(1), B.push_back(1), B.push_back(1);
}
}
else
{
for(int i = 31; i < (int)A.size(); ++i)
{
if(A[i] == 0) B.push_back(0);
else if(A[i + 1] == 0) B.push_back(1), B.push_back(1), B.push_back(0);
else B.push_back(1), B.push_back(1), B.push_back(1), B.push_back(1);
}
}
B.resize(last);
B.push_back(1);
for(int i = last + 1; i < N; ++i) B.push_back(0);
for(int i = 0; i < N; ++i) if(B[i]) last = i;
for(int i = 0; i < N; ++i) if(!B[i]) Remove(i);
for(int i = last - 1; i >= 0; --i) if(B[i]) Remove(i);
Remove(last);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
484 KB |
Wrong Answer [6] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
76 ms |
8624 KB |
Wrong Answer [6] |
2 |
Halted |
0 ms |
0 KB |
- |