| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1351875 | retarde | Ancient Machine (JOI21_ancient_machine) | C++20 | 49 ms | 13604 KiB |
#include "Anna.h"
#include <vector>
#include <bits/stdc++.h>
using namespace std;
namespace {
int variable_example = 0;
}
void Anna(int N, std::vector<char> S) {
variable_example++;
for (int i = 0; i < N; i++) {
if (S[i] == 'X') {
Send(0); Send(0);
} else if (S[i] == 'Y') {
Send(0); Send(1);
} else if (S[i] == 'Z') {
Send(1); Send(0);
}
}
}
#include "Bruno.h"
#include <vector>
#include <bits/stdc++.h>
using namespace std;
namespace {
int variable_example = 0;
int FunctionExample(int P) { return 1 - P; }
} // namespace
struct sg {
int l, r, i;
bool operator<(const sg &other) {
if (r != other.r) return r < other.r;
else if (l != other.l) return l < other.l;
else return i < other.i;
}
};
void Bruno(int N, int L, std::vector<int> A) {
for (int i = 0; i < L; i++) {
variable_example += FunctionExample(A[i]);
}
// for (int i = 0; i < N; i++) {
// Remove(i);
// }
vector<int> s(N);
for (int i = 0; i < L; i += 2) {
if (A[i] == 0 && A[i + 1] == 0) {
s[i/2] = -1;
} else if (A[i] == 0 && A[i + 1] == 1) {
s[i/2] = 0;
} else if (A[i] == 1 && A[i + 1] == 0) {
s[i/2] = 1;
} else {
assert(false);
}
}
vector<int> lx(N), rz(N);
int j = -1;
for (int i = 0; i < N; i++) {
if (s[i] == -1) j = i;
lx[i] = j;
}
j = 1e18;
for (int i = N - 1; i >= 0; i--) {
if (s[i] == 1) j = i;
rz[i] = j;
}
vector<sg> seg;
for (int i = 0; i < N; i++) {
if (s[i] != 0) continue;
if (lx[i] == -1) continue;
if (rz[i] == 1e18) continue;
seg.push_back({lx[i], rz[i], i});
}
sort(seg.begin(), seg.end());
vector<int> order; map<int, int> done;
int curr = -1e18;
for (auto &x : seg) {
// cout << x.l << " -> " << x.r << '\n';
if (x.l < curr) continue;
for (int j = x.l + 1; j < x.i; j++) {
done[j] = 1;
order.push_back(j);
}
for (int j = x.i + 1; j < x.r; j++) {
done[j] = 1;
order.push_back(j);
}
done[x.i] = 1;
order.push_back(x.i);
curr = x.r;
}
for (int i = 0; i < N; i++) {
if (!done[i]) order.push_back(i);
}
assert((int)order.size() == N);
for (auto &x : order) Remove(x);
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
