Submission #725041

#TimeUsernameProblemLanguageResultExecution timeMemory
725041piOOEAncient Machine (JOI21_ancient_machine)C++17
40 / 100
83 ms9108 KiB
#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 += 5) {
        int x = 0;
        for (int j = i; j < min(n, i + 5); ++j) {
            x = x * 3 + (s[j] == 'X' ? 0 : s[j] == 'Y' ? 1 : 2);
        }
        for (int _ = 0; (i + 5 >= n ? x : _ < 8); ++_) {
            Send(x % 2);
            x /= 2;
        }
    }
}
#include "Bruno.h"
#include <bits/stdc++.h>

using namespace std;

void Bruno(int N, int L, std::vector<int> A) {
    vector<char> s(N, 'X');
    int si = 0;
    for (int i = 0; i < L; i += 8, si += 5) {
        int x = 0;
        for (int j = i; j < min(L, i + 8); ++j) {
            x += (A[j]) << (j - i);
        }
        for (int sj = min(N, si + 5) - 1; sj >= si; --sj) {
            s[sj] = x % 3 == 0 ? 'X' : x % 3 == 1 ? 'Y' : 'Z';
            x /= 3;
        }
    }

    vector<int> stk;
    int xy = 0;

    for (int i = 0; i < N; ++i) {
        if (s[i] == 'Y') {
            if (!stk.empty()) {
                stk.push_back(i);
            } else {
                Remove(i);
            }
        } else if (s[i] == 'X') {
            stk.push_back(i);
        } else {
            while (stk.size() > 1) {
                Remove(stk.back());
                stk.pop_back();
            }
            Remove(i);
            xy = 0;
        }
    }
    for (int x : stk) {
        Remove(x);
    }
}

Compilation message (stderr)

Bruno.cpp: In function 'void Bruno(int, int, std::vector<int>)':
Bruno.cpp:21:9: warning: variable 'xy' set but not used [-Wunused-but-set-variable]
   21 |     int xy = 0;
      |         ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...