| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1320136 | PlayVoltz | Ancient Machine (JOI21_ancient_machine) | C++20 | 0 ms | 0 KiB |
#include "Anna.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define fi first
#define se second
void Anna(int n, vector<char> s){
for (int i=0; i<n; ++i){
if (s[i]=='X')Send(0), Send(0);
else if (s[i]=='Y')Send(1), Send(0);
else Send(1), Send(1);
}
}
#include "Bruno.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define fi first
#define se second
void Bruno(int n, int l, vector<int> a){
//x, y, z=0, 1, 2
vector<int> vect(n+1), y, lx(n+1, -1), ly(n+1, -1), lz(n+1, -1), rx(n+2, n+1), ry(n+2, n+1), rz(n+2, n+1);
for (int i=0; i<2*n; i+=2)vect[i/2+1]=a[i]+a[i+1];
for (int i=1; i<=n; ++i)if (vect[i]==1)y.pb(i);
set<int> s;
for (int i=1; i<=n; ++i)s.insert(i);
map<pii, int> mm;
for (int i=1; i<=n; ++i){
if (vect[i]==1)ly[i]=i;
else if (vect[i]==2)lz[i]=i;
else lx[i]=i;
lx[i]=max(lx[i], lx[i-1]);
ly[i]=max(ly[i], ly[i-1]);
lz[i]=max(lz[i], lz[i-1]);
}
for (int i=n; i>=1; --i){
if (vect[i]==1)ry[i]=i;
else if (vect[i]==2)rz[i]=i;
else rx[i]=i;
rx[i]=min(rx[i], rx[i+1]);
ry[i]=min(ry[i], ry[i+1]);
rz[i]=min(rz[i], rz[i+1]);
}
for (auto c:y)mm[mp(lx[c], rz[c])]=c;
vector<pair<pii, int> > ord;
for (auto c:mm)ord.pb(c);
sort(ord.begin(), ord.end(), custom);
for (auto aa:ord){
pii lr=aa.fi;
int c=aa.se;
if (lr.fi==-1||lr.se==n+1)continue;
vector<int> del;
for (auto it=s.upper_bound(lr.fi); it!=s.end()&&*it<lr.se; ++it)if (*it!=c)del.pb(*it);
for (auto a:del)Remove(a-1), s.erase(a);
Remove(c-1);
s.erase(c);
}
for (auto a:s)Remove(a-1);
}
