Submission #1071166

# Submission time Handle Problem Language Result Execution time Memory
1071166 2024-08-23T05:34:00 Z thinknoexit Ancient Machine (JOI21_ancient_machine) C++17
0 / 100
49 ms 9792 KB
#include "Anna.h"
#include<bits/stdc++.h>
using namespace std;
using ll = long long;

namespace {
    int n;
}
void Anna(int N, vector<char> S) {
    n = N;
    for (int i = 0;i < n;i++) {
        int v = S[i] - 'X';
        Send(!!(v & 1));
        Send(!!(v & 2));
    }
}
#include "Bruno.h"
#include<bits/stdc++.h>
using namespace std;
using ll = long long;

namespace {
    int n;
    int a[100100], pos[100100];
    bool ch[100100];
}  // namespace
void Bruno(int N, int L, vector<int> A) {
    n = N;
    for (int i = 0;i < n;i++) {
        a[i] = A[2 * i] + 2 * A[2 * i + 1];
    }
    stack<int> st;
    for (int i = 0;i < n;i++) {
        pos[i] = -1;
        if (a[i] == 2) continue;
        if (a[i] == 0) st.push(i);
        else {
            if (st.empty()) Remove(i);
            else {
                pos[i] = st.top();
                st.pop();
            }
        }
    }
    while (!st.empty()) {
        Remove(st.top());
        st.pop();
    }
    for (int i = 0;i < n;i++) {
        if (pos[i] != -1) {
            while (!st.empty() && pos[st.top()] > pos[i]) {
                Remove(st.top());
                Remove(pos[st.top()]);
                st.pop();
            }
            st.push(i);
            continue;
        }
        if (a[i] == 0 || a[i] == 1) continue;
        if (!st.empty()) {
            Remove(st.top());
            Remove(pos[st.top()]);
            st.pop();
        }
        Remove(i);
    }
    while (!st.empty()) {
        Remove(st.top());
        Remove(pos[st.top()]);
        st.pop();
    }
}

Compilation message

Bruno.cpp:9:10: warning: '{anonymous}::ch' defined but not used [-Wunused-variable]
    9 |     bool ch[100100];
      |          ^~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 796 KB Output is correct
2 Incorrect 0 ms 792 KB Wrong Answer [6]
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 49 ms 9792 KB Wrong Answer [6]
2 Halted 0 ms 0 KB -