#include "Anna.h"
/* Author : Mychecksdead */
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define MOD (1000000000+7)
#define MOD1 (998244353)
#define pb push_back
#define all(x) x.begin(), x.end()
#define en cout << '\n'
#define ff first
#define ss second
#define pii pair<int,int>
#define vi vector<int>
const int N = 2000+100, M = 1e5+10, K = 52, MX = 30;
namespace {
int variable_example = 0;
}
void Anna(int n, std::vector<char> S) {
stack<pair<int, char>> st;
vector<bool> A(n);
vector<bool> Z;
for(int i = 0; i < n; ++i){
if(st.empty() && S[i] == 'X'){
st.push({i, S[i]});
A[i] = 1;
Z.pb(0);
}else{
if(!st.empty()){
if(S[i] == 'X'){
if(st.top().ss == 'Y'){
st.push({i, S[i]});
Z.pb(0);
}
}else if(S[i] == 'Y'){
if(st.top().ss == 'X'){
st.push({i, S[i]});
}
}else{
if(st.size() == 1 || st.top().ss == 'Z'){
continue;
}
if(st.top().ss == 'X'){
st.pop();
Z.pop_back();
}
Z.pb(1);
A[i] = 1;
while(st.size() > 1){
A[st.top().ff] = 1;
st.pop();
}
}
}
}
}
for(int i = 0; i < n; ++i){
Send(A[i]);
}
for(int x: Z) Send(x);
}
#include "Bruno.h"
/* Author : Mychecksdead */
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define MOD (1000000000+7)
#define MOD1 (998244353)
#define pb push_back
#define all(x) x.begin(), x.end()
#define en cout << '\n'
#define ff first
#define ss second
#define pii pair<int,int>
#define vi vector<int>
const int N = 2000+100, M = 1e5+10, K = 52, MX = 30;
namespace {
int variable_example = 0;
int FunctionExample(int P) { return 1 - P; }
} // namespace
void Bruno(int n, int L, std::vector<int> A) {
int nice = 0;
vi R, Z;
for(int i = 0; i < n; ++i){
if(A[i] == 0){
Remove(i);
}else R.pb(i);
}
for(int i = n; i < L; ++i) Z.pb(A[i]);
if(R.empty()){
// do nothing
}else{
stack<int> st;
for(int i = 0; i < R.size(); ++i){
if(i % 2 == 1){
st.push(R[i]);
}else{
if(Z[i / 2]){
while(st.size() > 1){
Remove(st.top());
st.pop();
}
Remove(R[i]);
}else{
st.push(R[i]);
}
}
}
Remove(st.top());
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |