# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
548384 | TrungNotChung | Ancient Machine (JOI21_ancient_machine) | C++17 | 87 ms | 9176 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#define BIT(x,i) (1&((x)>>(i)))
#define MASK(x) (1LL<<(x))
#define CNT(x) __builtin_popcountll(x)
#include <bits/stdc++.h>
#include "Anna.h"
const char ch[] = {'X' , 'Y' , 'Z'};
long long pw[50];
void Anna(int N, std::vector<char> S) {
pw[0] = 1;
for(int i=1 ; i<=38 ; ++i) pw[i] = 1LL * pw[i-1] * 3;
for(int i=0 ; i<N ; i+=38)
{
long long tmp = 0;
for(int j=i ; j<=std::min(N-1 , i+37) ; ++j)
{
for(int k=0 ; k<3 ; ++k) if(S[j] == ch[k])
{
tmp += pw[j-i] * k;
}
}
for(int j=0 ; j<=62 ; ++j) Send(BIT(tmp , j));
}
}
#define BIT(x,i) (1&((x)>>(i)))
#define MASK(x) (1LL<<(x))
#define CNT(x) __builtin_popcountll(x)
#include <bits/stdc++.h>
#include "Bruno.h"
const char ch[] = {'X' , 'Y' , 'Z'};
long long pw[50];
void Bruno(int N, int L, std::vector<int> A)
{
std::vector<char> s;
for(int i=0 ; i<L ; i+=63)
{
long long tmp = 0;
for(int j=0 ; j<=62 ; ++j)
{
if(A[i+j] == 1) tmp += MASK(j);
}
for(int j=1 ; j<=38 ; ++j)
{
int c = tmp % 3;
tmp /= 3;
s.push_back(ch[c]);
if((int)s.size() == N) break;
}
}
std::stack<int> st;
for(int i=0 ; i<N ; ++i)
{
if(st.size() && s[i] == s[st.top()])
{
Remove(i);
continue;
}
if(s[i] == 'X')
{
st.push(i);
}
else if(s[i] == 'Y')
{
if(st.size()) st.push(i);
else Remove(i);
}
else
{
if((int)st.size() < 2)
{
Remove(i);
continue;
}
if(st.size() && s[st.top()] == 'X')
{
Remove(st.top());
st.pop();
}
while((int)st.size() > 2)
{
Remove(st.top());
st.pop();
Remove(st.top());
st.pop();
}
if((int)st.size() == 2)
{
Remove(st.top());
st.pop();
}
Remove(i);
}
}
while(st.size()) Remove(st.top()) , st.pop();
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |