#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) break;
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-2].first);
Remove(stk[s-1].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 |
Correct |
0 ms |
520 KB |
Output is correct |
2 |
Correct |
0 ms |
516 KB |
Output is correct |
3 |
Correct |
1 ms |
620 KB |
Output is correct |
4 |
Correct |
0 ms |
516 KB |
Output is correct |
5 |
Correct |
1 ms |
616 KB |
Output is correct |
6 |
Correct |
1 ms |
516 KB |
Output is correct |
7 |
Correct |
0 ms |
524 KB |
Output is correct |
8 |
Correct |
0 ms |
524 KB |
Output is correct |
9 |
Correct |
1 ms |
524 KB |
Output is correct |
10 |
Correct |
2 ms |
524 KB |
Output is correct |
11 |
Correct |
1 ms |
524 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
74 ms |
11268 KB |
Partially correct |
2 |
Partially correct |
77 ms |
11752 KB |
Partially correct |
3 |
Partially correct |
76 ms |
11744 KB |
Partially correct |
4 |
Partially correct |
73 ms |
11568 KB |
Partially correct |
5 |
Partially correct |
73 ms |
11664 KB |
Partially correct |
6 |
Partially correct |
77 ms |
11728 KB |
Partially correct |
7 |
Partially correct |
74 ms |
11760 KB |
Partially correct |
8 |
Partially correct |
70 ms |
11736 KB |
Partially correct |
9 |
Partially correct |
80 ms |
11716 KB |
Partially correct |
10 |
Partially correct |
84 ms |
11564 KB |
Partially correct |
11 |
Partially correct |
74 ms |
11632 KB |
Partially correct |
12 |
Partially correct |
75 ms |
11564 KB |
Partially correct |
13 |
Partially correct |
78 ms |
12760 KB |
Partially correct |
14 |
Partially correct |
83 ms |
11896 KB |
Partially correct |
15 |
Partially correct |
69 ms |
11652 KB |
Partially correct |
16 |
Partially correct |
67 ms |
12236 KB |
Partially correct |
17 |
Partially correct |
73 ms |
11180 KB |
Partially correct |
18 |
Partially correct |
82 ms |
11204 KB |
Partially correct |
19 |
Partially correct |
91 ms |
11112 KB |
Partially correct |
20 |
Partially correct |
70 ms |
12364 KB |
Partially correct |
21 |
Partially correct |
73 ms |
12260 KB |
Partially correct |
22 |
Partially correct |
91 ms |
11140 KB |
Partially correct |
23 |
Partially correct |
79 ms |
11988 KB |
Partially correct |
24 |
Partially correct |
68 ms |
12016 KB |
Partially correct |
25 |
Partially correct |
78 ms |
11232 KB |
Partially correct |
26 |
Partially correct |
83 ms |
11196 KB |
Partially correct |
27 |
Partially correct |
90 ms |
11248 KB |
Partially correct |
28 |
Partially correct |
84 ms |
11120 KB |
Partially correct |
29 |
Partially correct |
79 ms |
11148 KB |
Partially correct |
30 |
Partially correct |
80 ms |
11224 KB |
Partially correct |
31 |
Partially correct |
80 ms |
11108 KB |
Partially correct |
32 |
Partially correct |
73 ms |
11736 KB |
Partially correct |
33 |
Partially correct |
71 ms |
11692 KB |
Partially correct |