# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1071122 | 12345678 | Ancient Machine (JOI21_ancient_machine) | C++17 | 61 ms | 9892 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.
#include "Anna.h"
#include <bits/stdc++.h>
using namespace std;
void Anna(int N, std::vector<char> S) {
while ((S.size()%5)!=0) S.push_back('X');
vector<int> pw(10);
pw[0]=1;
for (int i=1; i<10; i++) pw[i]=pw[i-1]*3;
for (int i=0; i<S.size(); i+=5)
{
int tmp=0;
for (int j=0; j<5; j++) tmp+=(S[i+j]-'X')*pw[j];
for (int j=0; j<8; j++) Send(((tmp&(1<<j))>0));
}
}
#include "Bruno.h"
#include <bits/stdc++.h>
using namespace std;
const int nx=1e5+5;
int t[nx+20], curx=-1, cnt=0;
void Bruno(int N, int L, std::vector<int> A) {
for (int i=0; i<L; i+=8)
{
int tmp=0;
for (int j=0; j<8; j++) if (A[i+j]) tmp+=(1<<j);
for (int j=0; j<5; j++) t[cnt++]=tmp%3, tmp/=3;
}
stack<pair<int, int>> s;
for (int i=0; i<N; i++)
{
if (t[i]==0)
{
if (curx==-1) curx=i;
else Remove(i);
}
if (t[i]==1)
{
if (curx!=-1) s.push({curx, i}), curx=-1;
else Remove(i);
}
if (t[i]==2)
{
if (!s.empty())
{
if (curx!=-1) Remove(curx);
while (!s.empty())
{
Remove(s.top().second);
if (s.size()==1) curx=s.top().first;
else Remove(s.top().first);
s.pop();
}
}
Remove(i);
}
}
if (curx!=-1) Remove(curx);
while (!s.empty()) Remove(s.top().first), Remove(s.top().second), s.pop();
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |