# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
427504 | Osama_Alkhodairy | Ancient Machine (JOI21_ancient_machine) | C++17 | 88 ms | 9072 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "Anna.h"
using namespace std;
void Anna(int N, std::vector<char> S) {
int firstX = N;
for(int i = 0 ; i < N ; i++){
if(S[i] == 'X'){
firstX = i;
break;
}
}
int lastZ = N;
for(int i = N - 1 ; i >= 0 ; i--){
if(S[i] == 'Z'){
lastZ = i;
break;
}
}
for(int i = 16 ; i >= 0 ; i--){
Send((firstX >> i) & 1);
}
for(int i = 16 ; i >= 0 ; i--){
Send((lastZ >> i) & 1);
}
vector <int> f(N);
for(int i = firstX + 1 ; i < lastZ ; i++){
if(S[i] == 'Y' && S[i - 1] != 'Y'){
f[i] = 1;
if(S[i - 1] == 'Z') f[i - 1] = 1;
}
}
for(int i = 0 ; i < N ; i++){
Send(f[i]);
}
}
#include <bits/stdc++.h>
#include "Bruno.h"
using namespace std;
void Bruno(int N, int L, std::vector<int> A) {
reverse(A.begin(), A.end());
auto get = [&](){
assert(A.size());
int x = A.back();
A.pop_back();
return x;
};
int firstX = 0;
for(int i = 0 ; i < 17 ; i++){
firstX = 2 * firstX + get();
}
int lastZ = 0;
for(int i = 0 ; i < 17 ; i++){
lastZ = 2 * lastZ + get();
}
if(firstX == N || lastZ == N){
for(int i = 0 ; i < N ; i++){
Remove(i);
}
return;
}
string S(N, ';');
S[firstX] = 'X';
S[lastZ] = 'Z';
vector <int> f(N);
for(int i = 0 ; i < N ; i++){
f[i] = get();
}
for(int i = lastZ - 1 ; i > firstX ; i--){
if(f[i]){
S[i] = 'Y';
if(f[i - 1]) S[i - 1] = 'Z';
else S[i - 1] = 'X';
i--;
}
}
for(int i = 0 ; i < N ; i++){
if(S[i] == ';') Remove(i);
}
vector <int> g;
for(int i = 0 ; i < N ; i++){
if(S[i] == ';') continue;
if(S[i] == 'X'){
if(g.size() && S[g.back()] == 'X'){
Remove(i);
}
else g.push_back(i);
}
else if(S[i] == 'Y'){
g.push_back(i);
}
else{
if(g.size() && S[g.back()] == 'X'){
Remove(i);
}
else{
while(g.size() > 1){
Remove(g.back());
g.pop_back();
}
Remove(i);
}
}
}
for(auto &i : g) Remove(i);
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |