# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
752180 | Sam_a17 | Ancient Machine (JOI21_ancient_machine) | C++17 | 99 ms | 10876 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "Anna.h"
using namespace std;
void Send(int a);
void Anna(int N, std::vector<char> S) {
Send(0);
for(int i = 0; i < N; i++) {
if(S[i] == 'X') {
Send(0);
} else if(S[i] == 'Y') {
Send(1);
Send(0);
} else {
Send(1);
Send(1);
Send(0);
}
}
}
#include <bits/stdc++.h>
#include "Bruno.h"
using namespace std;
void Remove(int d);
void Bruno(int N, int L, std::vector<int> A) {
vector<int> a;
for(int i = 0; i < L - 1; i++) {
assert(A[i] == 0);
int j = i + 1, cnt = 0;
while(j < L && A[j] == 1) {
j++, cnt++;
}
if(cnt == 0) {
a.push_back(0);
} else if(cnt == 1) {
a.push_back(1);
} else {
a.push_back(2);
}
i = j - 1;
}
set<int> st[3];
auto dll = [&](int l, int r)-> void {
for(int i = 0; i < 3; i++) {
auto it = st[i].lower_bound(l);
vector<int> to_del;
while(it != st[i].end() && *it < r) {
to_del.push_back(*it);
it = next(it);
}
for(auto j: to_del) {
Remove(j);
st[i].erase(j);
}
}
};
for (int i = 0; i < N; i++) {
int ok = 0;
if(a[i] == 2) {
if(!st[1].empty() && !st[0].empty()) {
auto itr = *st[1].rbegin();
auto itl = *st[0].begin();
if(itl < itr) {
dll(itr + 1, i);
itl = *st[0].rbegin();
dll(itl + 1, itr);
//
st[1].erase(prev(st[1].end()));
Remove(itr);
ok = 1;
}
}
}
st[a[i]].insert(i);
}
for(int i = 0; i < 3; i++) {
for(auto j: st[i]) {
Remove(j);
}
}
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |