Submission #1008494

# Submission time Handle Problem Language Result Execution time Memory
1008494 2024-06-26T13:31:36 Z Unforgettablepl Ancient Machine (JOI21_ancient_machine) C++17
40 / 100
67 ms 10208 KB
#include "Anna.h"
#include <vector>
#include <bits/stdc++.h>
using namespace std;

namespace {
    int convert(vector<int> arr){
        int num = 0;
        for(int&i:arr){
            num*=3;
            num+=i;
        }
        return num;
    }
}

void Anna(int N, std::vector<char> S) {
    for(int i=N;i<100000;i++)S.emplace_back('X');
    for(int block = 0;block<100000;block+=5){
        vector<int> arr;
        for(int i=0;i<5;i++){
            if(S[i+block]=='X')arr.emplace_back(0);
            if(S[i+block]=='Y')arr.emplace_back(1);
            if(S[i+block]=='Z')arr.emplace_back(2);
        }
        int res = convert(arr);
        for(int bit=0;bit<8;bit++)Send(min(1,res&(1<<bit)));
    }
}
#include "Bruno.h"
#include <vector>
#include <bits/stdc++.h>
using namespace std;

namespace {
vector<int> convert(int x){
    vector<int> ans;
    for(int i=0;i<5;i++){
        ans.emplace_back(x%3);
        x/=3;
    }
    reverse(ans.begin(),ans.end());
    return ans;
}
}  // namespace

void Bruno(int N, int L, std::vector<int> A) {
    vector<int> arr;
    for(int i=0;i<160000;i+=8){
        int num=0;
        for(int bit=0;bit<8;bit++){
            num |= (A[i+bit]<<bit);
        }
        auto curr = convert(num);
        for(int&i:curr)arr.emplace_back(i);
    }
    arr.resize(N);
    list<pair<int,int>> curr = {{arr[0],0}};
    for(int i=1;i<N;i++)if(arr[i]==curr.back().first)Remove(i);
        else curr.emplace_back(arr[i],i);
    while(!curr.empty() and curr.front().first!=0){
        Remove(curr.front().second);
        curr.erase(curr.begin());
    }
    while(!curr.empty() and curr.back().first!=2){
        Remove(curr.back().second);
        curr.erase(--curr.end());
    }
    if(curr.empty())return;
    int last = 1;
    auto iter = curr.begin();
    while(iter!=curr.end()){
        if(iter->first==0){
            if(last==2 or last==0){
                Remove(iter->second);
                iter = curr.erase(iter);
            } else {
                last = 0;
                iter++;
            }
        } else if(iter->first==1){
            iter++;
            last = 1;
        } else if(iter->first==2){
            if(last==0 or last==2){
                if(iter->second==curr.back().second){
                    iter--;
                    Remove(iter->second);
                    iter = curr.erase(iter);
                    iter++;
                    continue;
                }
                Remove(iter->second);
                iter = curr.erase(iter);
            } else {
                last = 2;
                iter++;
            }
        }
    }
    if(curr.empty())return;
    if(curr.front().first!=0){
        Remove(curr.front().second);
        return;
    }
    iter = curr.begin();
    while(iter!=curr.end()){
        if(iter->first!=1){iter++;continue;}
        auto prev = iter++;
        if(iter->first==2){
            Remove(prev->second);
            assert(iter==curr.erase(prev));
            if(iter->second==curr.back().second){
                iter++;
            } else {
                Remove(iter->second);
                iter = curr.erase(iter);
            }
        } else iter++;
    }
    curr.reverse();
    iter = ++curr.begin();
    while(iter!=curr.end()){
        Remove(iter->second);
        iter = curr.erase(iter);
    }
    Remove(curr.front().second);
    curr.erase(curr.begin());
}
# Verdict Execution time Memory Grader output
1 Correct 19 ms 4176 KB Output is correct
2 Correct 19 ms 4168 KB Output is correct
3 Correct 19 ms 4164 KB Output is correct
4 Correct 20 ms 4112 KB Output is correct
5 Correct 24 ms 4164 KB Output is correct
6 Correct 19 ms 4168 KB Output is correct
7 Correct 22 ms 4380 KB Output is correct
8 Correct 19 ms 4384 KB Output is correct
9 Correct 20 ms 4160 KB Output is correct
10 Correct 19 ms 4172 KB Output is correct
11 Correct 19 ms 4160 KB Output is correct
# Verdict Execution time Memory Grader output
1 Partially correct 55 ms 9904 KB Partially correct
2 Partially correct 48 ms 9916 KB Partially correct
3 Partially correct 48 ms 10048 KB Partially correct
4 Partially correct 60 ms 9912 KB Partially correct
5 Partially correct 48 ms 9900 KB Partially correct
6 Partially correct 49 ms 9904 KB Partially correct
7 Partially correct 49 ms 9860 KB Partially correct
8 Partially correct 57 ms 9932 KB Partially correct
9 Partially correct 49 ms 9820 KB Partially correct
10 Partially correct 48 ms 9984 KB Partially correct
11 Partially correct 49 ms 9920 KB Partially correct
12 Partially correct 49 ms 9972 KB Partially correct
13 Partially correct 55 ms 9868 KB Partially correct
14 Partially correct 48 ms 9440 KB Partially correct
15 Partially correct 48 ms 9840 KB Partially correct
16 Partially correct 48 ms 10032 KB Partially correct
17 Partially correct 56 ms 9440 KB Partially correct
18 Partially correct 54 ms 9604 KB Partially correct
19 Partially correct 55 ms 9396 KB Partially correct
20 Partially correct 48 ms 10000 KB Partially correct
21 Partially correct 51 ms 9680 KB Partially correct
22 Partially correct 56 ms 9400 KB Partially correct
23 Partially correct 47 ms 9688 KB Partially correct
24 Partially correct 47 ms 9664 KB Partially correct
25 Partially correct 51 ms 9412 KB Partially correct
26 Partially correct 53 ms 9392 KB Partially correct
27 Partially correct 52 ms 9656 KB Partially correct
28 Partially correct 65 ms 9280 KB Partially correct
29 Partially correct 67 ms 9316 KB Partially correct
30 Partially correct 49 ms 9256 KB Partially correct
31 Partially correct 48 ms 9392 KB Partially correct
32 Partially correct 51 ms 10208 KB Partially correct
33 Partially correct 54 ms 10124 KB Partially correct