QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#325040#5596. I Could Have Wonthanhha1210WA 0ms3760kbC++17852b2024-02-11 03:36:142024-02-11 03:36:14

Judging History

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

  • [2024-02-11 03:36:14]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3760kb
  • [2024-02-11 03:36:14]
  • 提交

answer

#include <iostream>
#include <cmath>
#include <vector>
using namespace std;
int check(const string& s, int& k) {
    int cnt1 = 0, cnt2 = 0, k1 = 0, k2 = 0; // 1 is Alice, 2 is Bob
    int i = 0;
    while (i < s.length()) {
        if (s[i] == 'A')
            k1++;
        else 
            k2++;
        if (k1 == k) {
            cnt1++;
            k1 = k2 = 0;
        }
        else if (k2 == k) {
            cnt2++;
            k1 = k2 = 0;
        }
        i++;
    }
    if (cnt1 > cnt2)
        return true;
    return false;
}

int main() {
    string s;
    cin >> s;
    vector<int> res;
    for (int i = 1; i < s.length(); i++)
        if (check(s, i))
            res.emplace_back(i);
    cout << res.size() << endl;
    for (int i = 0; i < res.size(); i++)
        cout << res[i] << " ";
}
    

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3576kb

input:

BBAAABABBAAABB

output:

3
3 6 7 

result:

ok 2 lines

Test #2:

score: 0
Accepted
time: 0ms
memory: 3492kb

input:

AABBBAAB

output:

2
2 4 

result:

ok 2 lines

Test #3:

score: -100
Wrong Answer
time: 0ms
memory: 3760kb

input:

A

output:

0

result:

wrong answer 1st lines differ - expected: '1', found: '0'