#include "Anna.h"
#include <bits/stdc++.h>
using namespace std;
void Anna(int N, std::vector<char> S) {
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 Send(1), Send(0);
}
}
#include "Bruno.h"
#include <bits/stdc++.h>
using namespace std;
void Bruno(int N, int L, std::vector<int> A) {
vector<char> B(N, 0);
vector<bool> r(N, 0);
vector<int> tocl(N, -1), tocr(N, -1);
vector<pair<int, int> > segs;
for (int i = 0; i < L; i += 2) {
if (A[i] == 0 && A[i + 1] == 0) B[i] = 'X';
else if (A[i] == 0 && A[i + 1] == 1) B[i] = 'Y';
else B[i] = 'Z';
}
for (int i = 0, cl = -1; i < N; i++) {
if (B[i] == 'X') cl = i;
else if (B[i] == 'Y') tocl[i] = cl;
}
for (int i = N - 1, cr = -1; i >= 0; i--) {
if (B[i] == 'Z') cr = i;
else if (B[i] == 'Y') tocr[i] = cr;
}
for (int i = 0; i < N; i++)
if (B[i] == 'Y' && tocl[i] != -1 && tocr[i] != -1) {
segs.emplace_back(tocl[i], tocr[i]);
}
sort(segs.begin(), segs.end());
segs.erase(unique(segs.begin(), segs.end()), segs.end());
for (auto i : segs) {
assert(B[i.first] == 'X' && B[i.second] == 'Z');
int pos = -1;
for (int j = i.first; j <= i.second; j++)
if (!r[j] && B[j] == 'Y') pos = j;
assert(pos != -1);
for (int j = i.first + 1; j < pos; j++)
if (!r[j]) r[j] = 1, Remove(j);
for (int j = pos + 1; j < i.second; j++)
if (!r[j]) r[j] = 1, Remove(j);
Remove(pos);
}
for (int i = 0; i < N; i++)
if (!r[i]) Remove(i);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
612 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
52 ms |
7720 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |