제출 #1320137

#제출 시각아이디문제언어결과실행 시간메모리
1320137PlayVoltzAncient Machine (JOI21_ancient_machine)C++20
30 / 100
95 ms15332 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 bool custom(pair<pii, int> a, pair<pii, int> b){ return a.fi.se-a.fi.fi<b.fi.se-b.fi.fi; } 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); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...