답안 #426999

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
426999 2021-06-14T11:43:06 Z CodePlatina Ancient Machine (JOI21_ancient_machine) C++17
5 / 100
84 ms 8952 KB
#include "Anna.h"
#include <bits/stdc++.h>
#define pii pair<int, int>
#define ff first
#define ss second

using namespace std;

namespace
{

}

void Anna(int N, vector<char> S)
{
    int start = -1, last = -1;
    for(int i = 0; i < N; ++i)
    {
        if(start == -1 && S[i] == 'X') start = i;
        if(S[i] == 'Z') last = i;
    }

    vector<int> R;

    if(start == -1 || last == -1 || start > last)
    {
        Send(0);
        return;
    }

    Send(1);
    for(int i = 0; i < 14; ++i) Send(start >> i & 1);
    for(int i = 0; i < 14; ++i) Send(last >> i & 1);

    for(int i = start + 1; i < last; ++i)
    {
        if(S[i] == 'X' && S[i - 1] == 'Y') R.push_back(1);
        else if(S[i] == 'Y' && S[i + 1] == 'X') R.push_back(1);
        else R.push_back(0);
    }
    for(int i = last + 1; i < N; ++i) R.push_back(0);

    vector<int> Q{0, 0};
    int pt = 0;
    while(pt < (int)R.size())
    {
        if(R[pt] == 0) Q.push_back(0), ++pt;
        else Q.push_back(1), pt += 2;
    }

    vector<int> T{0, 1};
    pt = 0;
    while(pt < (int)R.size())
    {
        if(R[pt] == 0)
        {
            if(pt + 1 < (int)R.size() && R[pt + 1] == 0) T.push_back(0), pt += 2;
            else T.push_back(1), T.push_back(0), pt += 3;
        }
        else T.push_back(1), T.push_back(1), pt += 2;
    }

    if(T.size() < Q.size()) swap(T, Q);
    T = {1, 0};
    pt = 0;
    while(pt < (int)R.size())
    {
        if(R[pt] == 1)
        {
            if(pt + 2 < (int)R.size() && R[pt + 2] == 0) T.push_back(0), pt += 3;
            else T.push_back(1), T.push_back(1), pt += 4;
        }
        else T.push_back(1), T.push_back(0), ++pt;
    }

    if(T.size() < Q.size()) swap(T, Q);
    T = {1, 1};
    pt = 0;
    while(pt < (int)R.size())
    {
        if(R[pt] == 1)
        {
            if(pt + 2 < (int)R.size() && R[pt + 2] == 0) T.push_back(1), T.push_back(0), pt += 3;
            else T.push_back(1), T.push_back(1), pt += 4;
        }
        else T.push_back(0), ++pt;
    }

    if(T.size() < Q.size()) swap(T, Q);

    for(auto i : Q) Send(i);
}
#include "Bruno.h"
#include <bits/stdc++.h>

using namespace std;

namespace
{

}

void Bruno(int N, int L, vector<int> A)
{
    if(A[0] == 0)
    {
        for(int i = 0; i < N; ++i) Remove(i);
        return;
    }

    int start = 0, last = 0;
    for(int i = 0; i < 14; ++i) if(A[i + 1]) start += 1 << i;
    for(int i = 0; i < 14; ++i) if(A[i + 15]) last += 1 << i;

    vector<int> B;
    for(int i = 0; i < start; ++i) B.push_back(0);
    B.push_back(1);

    if(A[29] == 0 && A[30] == 0)
    {
        for(int i = 31; i < (int)A.size(); ++i)
        {
            if(A[i] == 0) B.push_back(0);
            else B.push_back(1), B.push_back(1);
        }
    }
    else if(A[29] == 0 && A[30] == 1)
    {
        for(int i = 31; i < (int)A.size(); i += 2)
        {
            if(A[i] == 0) B.push_back(0), B.push_back(0), --i;
            else if(A[i + 1] == 0) B.push_back(0), B.push_back(1), B.push_back(1);
            else B.push_back(1), B.push_back(1);
        }
    }
    else if(A[29] == 1 && A[30] == 0)
    {
        for(int i = 31; i < (int)A.size(); i += 2)
        {
            if(A[i] == 0) B.push_back(1), B.push_back(1), B.push_back(0), --i;
            else if(A[i + 1] == 0) B.push_back(0);
            else B.push_back(1), B.push_back(1), B.push_back(1), B.push_back(1);
        }
    }
    else
    {
        for(int i = 31; i < (int)A.size(); i += 2)
        {
            if(A[i] == 0) B.push_back(0), --i;
            else if(A[i + 1] == 0) B.push_back(1), B.push_back(1), B.push_back(0);
            else B.push_back(1), B.push_back(1), B.push_back(1), B.push_back(1);
        }
    }

    B.resize(last);
    B.push_back(1);
    for(int i = last + 1; i < N; ++i) B.push_back(0);

    for(int i = 0; i < N; ++i) if(B[i]) last = i;
    for(int i = 0; i < N; ++i) if(!B[i]) Remove(i);
    for(int i = last - 1; i >= 0; --i) if(B[i]) Remove(i);
    Remove(last);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 488 KB Output is correct
2 Correct 2 ms 488 KB Output is correct
3 Correct 1 ms 488 KB Output is correct
4 Correct 1 ms 488 KB Output is correct
5 Correct 2 ms 488 KB Output is correct
6 Correct 2 ms 568 KB Output is correct
7 Correct 1 ms 488 KB Output is correct
8 Correct 2 ms 540 KB Output is correct
9 Correct 1 ms 488 KB Output is correct
10 Correct 1 ms 488 KB Output is correct
11 Correct 1 ms 488 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 84 ms 8952 KB Wrong Answer [6]
2 Halted 0 ms 0 KB -