# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1071219 | Plurm | Ancient Machine (JOI21_ancient_machine) | C++17 | 2012 ms | 4908 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "Anna.h"
#include <vector>
namespace {
int variable_example = 0;
}
void Anna(int N, std::vector<char> S) {
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);
}
}
}
#include "Bruno.h"
#include <bits/stdc++.h>
using namespace std;
namespace {
void resolve(vector<int> &ord, vector<vector<int>> &dp,
vector<vector<int>> &par, int l, int r) {
if (l > r)
return;
if (l == r) {
ord.push_back(l);
return;
}
if (par[l][r] >= 0) {
resolve(ord, dp, par, l, par[l][r]);
resolve(ord, dp, par, par[l][r] + 1, r);
} else {
resolve(ord, dp, par, l, ~par[l][r] - 1);
if (find(ord.begin(), ord.end(), l) != ord.end())
ord.erase(find(ord.begin(), ord.end(), l));
resolve(ord, dp, par, ~par[l][r] + 1, r);
if (find(ord.begin(), ord.end(), r) != ord.end())
ord.erase(find(ord.begin(), ord.end(), r));
ord.push_back(~par[l][r]);
ord.push_back(l);
ord.push_back(r);
}
}
} // namespace
void Bruno(int N, int L, std::vector<int> A) {
string target;
int ptr = 0;
while (ptr < L) {
if (A[ptr++] == 0)
target.push_back('X');
else if (A[ptr++] == 0)
target.push_back('Y');
else
target.push_back('Z');
}
bool done = false;
vector<int> ord;
int chosen = -1;
do {
vector<int> prefX(N, -1);
for (int i = 0; i < N; i++) {
if (target[i] == 'X')
prefX[i] = i;
else
prefX[i] = i ? prefX[i - 1] : -1;
}
vector<int> suffZ(N, N);
for (int i = N - 1; i >= 0; i--) {
if (target[i] == 'Z')
suffZ[i] = i;
else
suffZ[i] = i == N - 1 ? N : suffZ[i + 1];
}
int mn = 1e9;
chosen = -1;
for (int i = 0; i < N; i++) {
if (target[i] == 'Y' && prefX[i] != -1 && suffZ[i] != N) {
int c = 0;
for (int j = prefX[i] + 1; j <= suffZ[i] - 1; j++) {
if (j == i)
continue;
if (target[j] != '\0')
c++;
}
if (c < mn) {
mn = c;
chosen = i;
}
}
}
if (chosen != -1) {
for (int j = prefX[chosen] + 1; j <= suffZ[chosen] - 1; j++) {
if (j == chosen)
continue;
if (target[j] != '\0') {
ord.push_back(j);
target[j] = '\0';
}
}
ord.push_back(chosen);
target[chosen] = '\0';
}
} while (chosen != -1);
for (int i = 0; i < N; i++) {
if (target[i] != '\0')
ord.push_back(i);
}
for (int x : ord)
Remove(x);
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |