#include "Anna.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
namespace nAnna{
int n;
int s[100005];
void Anna(int N, vector<char> _s){
n = N;
for(int i=1; i<=n; i++) s[i] = _s[i-1] - 'X';
for(int i=1; i<=n; i++){
Send(s[i]/2), Send(s[i]%2);
}
}
}
void Anna(int N, vector<char> S){
return nAnna::Anna(N, S);
}
#include "Bruno.h"
#include <bits/stdc++.h>
using namespace std;
namespace nBruno{
int n, k;
int arr[100002];
bool removed[100002];
int first0=-1, last2=-1, last1=-1;
vector<pair<int, int> > vec;
vector<pair<int, int> > stk;
void remove(int x){
Remove(x);
removed[x] = 1;
}
void Bruno(int _n, int _l, vector<int> _vec){
n = _n, k = _l;
for(int i=0; i<n; i++){
arr[i] = _vec[i*2] * 2 + _vec[i*2+1];
}
for(int i=0; i<n; i++){
if(arr[i] == 0){
first0 = i;
break;
}
else remove(i);
}
if(first0<0) return;
for(int i=n-1; i>=first0; i--){
if(arr[i] == 2){
last2 = i;
break;
}
else remove(i);
}
if(last2<0) return;
for(int i=last2-1; i>=first0; i--){
if(arr[i] == 1){
last1 = i;
break;
}
else remove(i);
}
if(last1<0){
Remove(last2);
return;
}
for(int i=0; i<n; i++){
if(removed[i]) continue;
if(vec.empty()){
if(arr[i] != 0) Remove(i);
else vec.push_back(make_pair(i, arr[i]));
}
else if(vec.back().second == 1){
if(arr[i] == 1) Remove(i);
else vec.push_back(make_pair(i, arr[i]));
}
else{
if(arr[i] != 1) Remove(i);
else vec.push_back(make_pair(i, arr[i]));
}
}
for(int i=0; i<(int)vec.size(); i++){
assert((i%2) == (vec[i].second==1));
stk.push_back(vec[i]);
while((int)stk.size() >= 3){
int s = (int)stk.size();
if(stk[s-1].second != 2 || stk[s-2].second != 1 || stk[s-3].second != 0) continue;
if(stk[s-1].first == last2){ /// 2�� ���� �� ��
Remove(stk[s-2].first);
Remove(stk[s-3].first);
auto tmp = stk.back();
stk.pop_back();
stk.pop_back();
stk.pop_back();
stk.push_back(tmp);
}
else{ /// 2�� ���� ����
Remove(stk[s-1].first);
Remove(stk[s-2].first);
stk.pop_back();
stk.pop_back();
}
}
}
while(!stk.empty()){
Remove(stk.back().first);
stk.pop_back();
}
}
}
void Bruno(int N, int L, vector<int> A){
nBruno::Bruno(N, L, A);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
620 KB |
Wrong Answer [6] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2065 ms |
9252 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |