# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
996639 | hotboy2703 | Ancient Machine (JOI21_ancient_machine) | C++17 | 34 ms | 10068 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 ll = int;
using namespace std;
#define pll pair <ll,ll>
#define fi first
#define se second
#define MP make_pair
#define sz(a) (ll((a).size()))
#define BIT(mask,i) (((mask) >> (i))&1)
#define MASK(i) (1LL << (i))
namespace A{
struct pt{
ll type,l,r;
};
}
void Anna(int N, std::vector<char> S) {
using namespace A;
vector <ll> a;
for (ll i = 0;i < N;i ++){
a.push_back(S[i]-'X');
}
// for (auto x:a)cout<<x<<' ';
// cout<<'\n';
vector <ll> res(N);
vector <pt> nw;
for (ll i = 0;i < N;i ++){
ll j = i;
while (j + 1 < N && a[j+1] == a[i])j++;
nw.push_back({a[i],i,j});
i = j;
}
while (!nw.empty() && nw.back().type != 2){
nw.pop_back();
}
ll last0 = -1;
for (ll i = 0;i < sz(nw);i ++){
if (last0 == -1){
if (nw[i].type == 0){res[nw[i].l] = 1;last0 = i;}
}
else{
ll j = i;
while (nw[j].type != 2)j++;
bool ok = 0;
for (ll k = j-1;k >= i;k --){
if (nw[k].type==1)ok = 1;
}
res[nw[j].r] = ok;
i = j;
}
}
// for (auto x:res)cout<<x<<' ';
// cout<<'\n';
for (auto x:res)Send(x);
}
#include "Bruno.h"
#include<bits/stdc++.h>
using ll = int;
using namespace std;
#define pll pair <ll,ll>
#define fi first
#define se second
#define MP make_pair
#define sz(a) (ll((a).size()))
#define BIT(mask,i) (((mask) >> (i))&1)
#define MASK(i) (1LL << (i))
namespace B{
} // namespace
void Bruno(int N, int L, std::vector<int> A) {
using namespace B;
vector <ll> a = A;
vector <bool> del(N);
ll last = -1;
ll first = -1;
for (ll i = 0;i < N;i ++){
if (A[i]){
if (first==-1)first = A[i];
else{
for (ll j = i - 1;j > last;j --){del[j] = 1;Remove(j);}
del[i] = 1;Remove(i);
}
last = i;
}
}
for (ll i = 0;i < N;i ++){
if (!del[i]){
Remove(i);
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |