QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#788337#9565. Birthday GiftHansWA 1ms3804kbC++23892b2024-11-27 16:35:432024-11-27 16:35:48

Judging History

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

  • [2024-11-27 16:35:48]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3804kb
  • [2024-11-27 16:35:43]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

void solve() {
  string str; cin >> str;
  str.push_back('b');
  vector<int> v;
  stack<int> s;

  char cur = str[0];
  bool seq_is_odd = false;

  for (int i = 0; i < str.size(); i++) {
    if (str[i] == cur)
      seq_is_odd = !seq_is_odd;
    else {
      if (seq_is_odd) v.push_back(cur);

      if (str[i] == '2') {
        v.push_back('2');
        i++;
      } 
      cur = str[i];
      seq_is_odd = true;
    }
  }

  // cout << "Vect: ";
  // for (auto i : v) cout << (char)i << ' ';
  // cout << endl;

  if (s.size() == str.size()) {
    cout << s.size() << '\n';
    return;
  }

  for (char c : v) {
    if (s.size() && (c == s.top() || s.top() == '2')) s.pop();
    else s.push(c);
  }

  cout << s.size() << '\n';
}

int main() {
  int n; cin >> n;
  while (n--)
    solve();
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3804kb

input:

5
0110101
01020102
0000021111
1012121010
0100202010

output:

3
6
2
6
0

result:

wrong answer 2nd numbers differ - expected: '4', found: '6'