#include "Anna.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ii pair<ll,ll>
#define fi first
#define se second
#define endl '\n'
#define puf push_front
#define pof pop_front
#define pub push_back
#define pob pop_back
#define lb lower_bound
#define ub upper_bound
#define rep(x,s,e) for (auto x=s-(s>e);x!=e-(s>e);(s<e?x++:x--))
#define all(x) (x).begin(),(x).end()
#define sz(x) (int) (x).size()
namespace {
int n;
string s;
const string ss[]={"?X","?Y","?Z","XY","YX","YZ","ZX","ZY"};
}
//XZ is useless just make it Z?
void Anna(int N, std::vector<char> S) {
n=N;
rep(x,0,n) s+=S[x];
if (n%2==1) s+=s.back(),n++;
for (int x=0;x<n;x+=2){
if (s[x]==s[x+1]) s[x]='?';
string sub=s.substr(x,2);
if (sub=="XZ") sub="?Z";
rep(bm,0,8) if (sub==ss[bm]){
//cout<<"bitmask: "<<bm<<endl;
int curr=4;
rep(y,0,3){
if (bm&curr) Send(1);
else Send(0);
curr>>=1;
}
}
}
}
#include "Bruno.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ii pair<ll,ll>
#define fi first
#define se second
#define endl '\n'
#define puf push_front
#define pof pop_front
#define pub push_back
#define pob pop_back
#define lb lower_bound
#define ub upper_bound
#define rep(x,s,e) for (auto x=s-(s>e);x!=e-(s>e);(s<e?x++:x--))
#define all(x) (x).begin(),(x).end()
#define sz(x) (int) (x).size()
namespace {
int n,l;
vector<int> bits;
string s;
const string ss[]={"?X","?Y","?Z","XY","YX","YZ","ZX","ZY"};
} // namespace
void Bruno(int N, int L, std::vector<int> A) {
n=N,l=L,bits=A;
//for (auto &it:bits) cout<<it<<" "; cout<<endl;
rep(x,0,l/3){
int num=4*bits[x*3]+2*bits[x*3+1]+bits[x*3+2];
//cout<<"received: "<<num<<endl;
s+=ss[num];
}
if (n%2==1) s.erase(s.begin()+n-1);
//cout<<s<<endl;
vector<int> stk;
rep(x,0,n){
if (s[x]=='X'){
if (sz(stk)%2==0) stk.pub(x);
else Remove(x);
}
else if (s[x]=='Y'){
if (sz(stk)%2==1) stk.pub(x);
else Remove(x);
}
else if (s[x]=='Z'){
while (sz(stk)>1){
Remove(stk.back());
stk.pob();
}
Remove(x);
}
else{
Remove(x);
}
}
while (!stk.empty()){
Remove(stk.back());
stk.pob();
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
484 KB |
Output is correct |
2 |
Correct |
0 ms |
484 KB |
Output is correct |
3 |
Correct |
1 ms |
484 KB |
Output is correct |
4 |
Correct |
1 ms |
484 KB |
Output is correct |
5 |
Correct |
0 ms |
484 KB |
Output is correct |
6 |
Correct |
1 ms |
484 KB |
Output is correct |
7 |
Correct |
0 ms |
484 KB |
Output is correct |
8 |
Correct |
0 ms |
484 KB |
Output is correct |
9 |
Correct |
0 ms |
492 KB |
Output is correct |
10 |
Correct |
0 ms |
484 KB |
Output is correct |
11 |
Correct |
0 ms |
484 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
80 ms |
9352 KB |
Partially correct |
2 |
Partially correct |
81 ms |
9420 KB |
Partially correct |
3 |
Incorrect |
84 ms |
9316 KB |
Wrong Answer [6] |
4 |
Halted |
0 ms |
0 KB |
- |