QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#236214 | #6442. Secret of Tianqiu Valley | ucup-team1001# | WA | 1ms | 3468kb | C++17 | 3.4kb | 2023-11-03 18:29:11 | 2023-11-03 18:29:12 |
Judging History
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();
rep(i, 0, n) {
cout << ans_v[i] << " \n"[i == n - 1];
}
}
int main() {
IOS
int t;
cin >> t;
while (t--)solve();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3468kb
input:
2 5 00000 3 001
output:
1 2 3 4 5 0
result:
wrong answer puzzle unsolved (test case 1)