QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#731161#9565. Birthday Giftucup-team5226#WA 0ms3848kbC++203.3kb2024-11-10 00:15:212024-11-10 00:15:21

Judging History

你现在查看的是最新测评结果

  • [2024-11-10 00:15:21]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3848kb
  • [2024-11-10 00:15:21]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
template <class T>
using vc = vector<T>;
template <class T>
using vvc = vc<vc<T>>;
template <class T>
using vvvc = vc<vvc<T>>;
#define overload5(a, b, c, d, e, name, ...) name
#define overload4(a, b, c, d, name, ...) name
#define overload3(a, b, c, name, ...) name
#define rep1(n) for (ll i = 0; i < n; ++i)
#define rep2(i, n) for (ll i = 0; i < n; ++i)
#define rep3(i, a, b) for (ll i = a; i < b; ++i)
#define rep4(i, a, b, c) for (ll i = a; i < b; i += c)
#define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep1(n) for (ll i = n; i--;)
#define rrep2(i, n) for (ll i = n; i--;)
#define rrep3(i, a, b) for (ll i = b; i-- > (a);)
#define rrep(...) overload4(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define each1(i, a) for (auto &&i : a)
#define each2(x, y, a) for (auto &&[x, y] : a)
#define each3(x, y, z, a) for (auto &&[x, y, z] : a)
#define each4(w, x, y, z, a) for (auto &&[w, x, y, z] : a)
#define each(...) overload5(__VA_ARGS__, each4, each3, each2, each1)(__VA_ARGS__)
#define all1(i) begin(i), end(i)
#define all2(i, a) begin(i), begin(i) + a
#define all3(i, a, b) begin(i) + a, begin(i) + b
#define all(...) overload3(__VA_ARGS__, all3, all2, all1)(__VA_ARGS__)
#define rall1(i) rbegin(i), rend(i)
#define rall2(i, a) rbegin(i), rbegin(i) + a
#define rall3(i, a, b) rbegin(i) + a, rbegin(i) + b
#define rall(...) overload3(__VA_ARGS__, rall3, rall2, rall1)(__VA_ARGS__)
template <class T>
bool chmin(T &a, const T &b) {
    if (a <= b) return 0;
    a = b;
    return 1;
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a >= b) return 0;
    a = b;
    return 1;
}
template <class T, class U>
bool chmin(T &a, const U &b) {
    return chmin(a, (T)b);
}
template <class T, class U>
bool chmax(T &a, const U &b) {
    return chmax(a, (T)b);
}
void solve();
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    ll t = 1;
    cin >> t;
    for (int i = 1; i <= t; i++) solve();
    return 0;
}
ll dy[] = {0, 0, 1, 0, -1}, dx[] = {0, 1, 0, -1, 0};
// ll dy[8] = {1, 1, 0, -1, -1, -1, 0, 1}, dx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
void solve() {
    string s;
    cin >> s;
    stack<char> st;
    for (auto c : s) {
        if (st.empty()) {
            st.push(c);
            continue;
        }
        if (c != '2') {
            if (st.top() == c)
                st.pop();
            else
                st.push(c);
        } else
            st.push(c);
    }
    string t;
    while (!st.empty()) {
        t.push_back(st.top());
        st.pop();
    }
    string tmp;
    for (auto c : t) {
        tmp.push_back(c);
        if (tmp.ends_with("020")) tmp.pop_back(), tmp.pop_back();
        if (tmp.ends_with("121")) tmp.pop_back(), tmp.pop_back();
        if (tmp.ends_with("01201"))
            tmp.pop_back(), tmp.pop_back(), tmp.pop_back(), tmp.pop_back(), tmp.pop_back(), tmp.push_back('2');
        if (tmp.ends_with("10210"))
            tmp.pop_back(), tmp.pop_back(), tmp.pop_back(), tmp.pop_back(), tmp.pop_back(), tmp.push_back('2');
    }
    ll res = tmp.size();
    cout << res % 2 << endl;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3848kb

input:

5
0110101
01020102
0000021111
1012121010
0100202010

output:

1
0
0
0
0

result:

wrong answer 1st numbers differ - expected: '3', found: '1'