QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#236218#6442. Secret of Tianqiu Valleyucup-team1001#WA 0ms3596kbC++173.5kb2023-11-03 18:30:482023-11-03 18:30:48

Judging History

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

  • [2023-11-03 18:30:48]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3596kb
  • [2023-11-03 18:30:48]
  • 提交

answer

#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ull = unsigned long long;

#define IOS ios::sync_with_stdio(0);cin.tie(0);
#define endl "\n"
#define rep(i, a, b) for(int i = (a); i < (b); ++i)


void solve() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int> vis(n);
    vector<int> ans(n);
    auto is0 = [&](int i) {
        return !((s[i] - '0') ^ (vis[i] % 2));
    };
    rep(i, 0, n - 2) {
        if (is0(i)) {
            vis[i]++;
            vis[i + 1]++;
            vis[i + 2]++;
            ans[i + 1]++;
        }
    }
    int k = n / 3;
    int last2 = (1 - is0(n - 2)) * 2 + (1 - is0(n - 1));
//    rep(i, 0, n) {
//        cout << ans[i] << " ";
//    }
//    cout << endl;
//    rep(i, 0, n) {
//        cout << (is0(i) ? '0' : '1');
//    }
//    cout << endl;
//    rep(i, 0, n) {
//        cout << vis[i] << " ";
//    }
//    cout << endl;
//    cout << last2 << endl;
    switch (n % 3) {
        case 0: {
            switch (last2) {
                case 0b00:
                case 0b01:
                case 0b10: {
                    cout << "0\n";
                    return;
                }
                case 0b11: {
                    rep(i, 0, n) {
                        ans[i]++;
                    }
                    break;
                }
            }
            break;
        }
        case 1: {
            switch (last2) {
                case 0b00: {
                    rep(i, 0, k) {
                        ans[3 * i + 2]++;
                    }
                    ans[n - 1]++;
                    break;
                }
                case 0b01: {
                    rep(i, 0, k) {
                        ans[3 * i]++;
                    }
                    break;
                }
                case 0b10: {
                    rep(i, 0, k) {
                        ans[3 * i + 1]++;
                    }
                    break;
                }
                case 0b11: {
                    rep(i, 0, n) {
                        ans[i]++;
                    }
                    break;
                }
            }
            break;
        }
        case 2: {
            switch (last2) {
                case 0b00: {
                    rep(i, 0, k) {
                        ans[3 * i + 1]++;
                    }
                    break;
                }
                case 0b01: {
                    rep(i, 0, k) {
                        ans[3 * i + 2]++;
                    }
                    ans[n - 1]++;
                    break;
                }
                case 0b10: {
                    rep(i, 0, k) {
                        ans[3 * i + 3]++;
                    }
                    ans[0]++;
                    break;
                }
                case 0b11: {
                    rep(i, 0, n) {
                        ans[i]++;
                    }
                    break;
                }
            }
            break;
        }
    }
//    rep(i, 0, n) {
//        cout << ans[i] << " ";
//    }
//    cout << endl;
    vector<int> ans_v;
    rep(i, 0, n) {
        if (!(ans[i] % 2))ans_v.emplace_back(i + 1);
    }
    n = (int) ans_v.size();
    cout << n << endl;
    rep(i, 0, n) {
        cout << ans_v[i] << " \n"[i == n - 1];
    }
}

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

詳細信息

Test #1:

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

input:

2
5
00000
3
001

output:

5
1 2 3 4 5
0

result:

wrong answer ignite ignited torch (test case 1)