QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#248409 | #6442. Secret of Tianqiu Valley | chengch | RE | 1ms | 3792kb | C++14 | 1.1kb | 2023-11-11 19:02:21 | 2023-11-11 19:02:22 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
using namespace std;
void solve(){
int n;string s;cin>>n>>s;
vector<int> x(n),y(n);
for(int i=0;i<n;i++)x[i]=s[i]-'0';
vector<int> ans;
auto op=[&](int i){
assert(x[i]==0);
x[i]^=1,x[(i+1)%n]^=1,x[(i-1+n)%n]^=1,y[i]^=1;
ans.push_back(i);
};
for(y[0]=0;y[0]<2;y[0]++)
for(y[1]=0;y[1]<2;y[1]++){
for(int i=2;i<n;i++)y[i]=y[i-2]^y[i-1]^x[i-1]^1;
bool ok=true;
for(int i=0;i<n;i++){
int now=x[i]^y[i]^y[(i-1+n)%n]^y[(i+1)%n];
if(now==0){
ok=false;
break;
}
}
if(!ok)continue;
for(int t=0;t<1000;t++){
for(int i=0;i<n;i++)if(x[i]==0&&y[i]==1)op(i);
}
for(int t=0;t<1000;t++){
for(int i=0;i<n;i++)if(x[i]==1&&y[i]==1){
int l=(i-1+n)%n,r=(i+1)%n;
if(x[r]==0&&y[r]==0){
op(r);op(i);op(l);op(r);
}else{
op(l);op(i);op(r);op(l);
}
}
}
cout<<ans.size()<<endl;
for(auto x:ans)cout<<x+1<<' ';cout<<endl;
return;
}
cout<<0<<endl;
}
signed main(){
int t;cin>>t;
while(t--)solve();
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3584kb
input:
2 5 00000 3 001
output:
7 1 3 2 3 4 5 3 0
result:
ok all puzzle solved (2 test cases)
Test #2:
score: 0
Accepted
time: 0ms
memory: 3792kb
input:
7 3 000 3 100 3 010 3 110 3 001 3 101 3 011
output:
1 3 0 0 0 0 0 0
result:
ok all puzzle solved (7 test cases)
Test #3:
score: 0
Accepted
time: 1ms
memory: 3508kb
input:
15 4 0000 4 1000 4 0100 4 1100 4 0010 4 1010 4 0110 4 1110 4 0001 4 1001 4 0101 4 1101 4 0011 4 1011 4 0111
output:
4 1 3 4 2 1 3 1 4 4 4 1 2 4 1 1 2 2 4 4 1 2 3 1 3 4 1 3 1 2 4 2 1 4 2 2 1 3 3 3 4 2 4 2 3 4 2 3 2 3 1 3 1 2 4
result:
ok all puzzle solved (15 test cases)
Test #4:
score: 0
Accepted
time: 1ms
memory: 3588kb
input:
31 5 00000 5 10000 5 01000 5 11000 5 00100 5 10100 5 01100 5 11100 5 00010 5 10010 5 01010 5 11010 5 00110 5 10110 5 01110 5 11110 5 00001 5 10001 5 01001 5 11001 5 00101 5 10101 5 01101 5 11101 5 00011 5 10011 5 01011 5 11011 5 00111 5 10111 5 01111
output:
7 1 3 2 3 4 5 3 2 2 5 2 1 3 1 4 2 2 4 3 2 3 1 1 5 6 4 3 2 1 5 2 2 3 5 3 5 1 4 3 3 4 2 4 5 1 2 5 1 1 4 2 3 4 2 6 1 2 3 4 5 3 5 5 1 2 3 1 2 1 4 1 3 3 1 2 5 6 3 2 3 4 5 3 3 4 5 3 4 2 1 5 2 4 1 2 3 1 5 4 5 1 2 5 1 2 6 2 1 2 3 4 2 4 3 4 5 3 5 3 2 1 5 2 6 1 5 1 2 3 1 5 2 3 4 5...
result:
ok all puzzle solved (31 test cases)
Test #5:
score: 0
Accepted
time: 1ms
memory: 3588kb
input:
63 6 000000 6 100000 6 010000 6 110000 6 001000 6 101000 6 011000 6 111000 6 000100 6 100100 6 010100 6 110100 6 001100 6 101100 6 011100 6 111100 6 000010 6 100010 6 010010 6 110010 6 001010 6 101010 6 011010 6 111010 6 000110 6 100110 6 010110 6 110110 6 001110 6 101110 6 011110 6 111110 6 000001 ...
output:
2 3 6 0 0 0 0 0 0 1 5 0 2 3 5 0 0 0 0 1 6 0 0 0 2 4 6 0 0 3 4 5 3 0 0 0 0 0 4 3 4 5 3 5 6 2 3 4 2 0 0 0 0 0 0 1 4 6 4 3 4 5 6 4 0 0 0 0 0 3 5 6 4 0 0 4 2 3 4 2 0 0 0 1 3 0 0 0 0 4 4 5 6 4 0 5 3 4 5 6 4 0 0 0 0 0 0
result:
ok all puzzle solved (63 test cases)
Test #6:
score: -100
Runtime Error
input:
127 7 0000000 7 1000000 7 0100000 7 1100000 7 0010000 7 1010000 7 0110000 7 1110000 7 0001000 7 1001000 7 0101000 7 1101000 7 0011000 7 1011000 7 0111000 7 1111000 7 0000100 7 1000100 7 0100100 7 1100100 7 0010100 7 1010100 7 0110100 7 1110100 7 0001100 7 1001100 7 0101100 7 1101100 7 0011100 7 1011...
output:
9 1 3 5 2 4 5 6 7 5 2 3 6 2 4 7 5 5 7 1 2 7 2 1 5 3 2 4 7 5 6 1 2 3 1 8 4 6 3 5 2 1 7 2 2 2 6 5 5 7 1 4 6 3 1 3 5 4 3 4 7 2 5 7 2 3 4 2 4 2 3 5 1 8 1 2 5 4 5 6 7 5 1 6 2 3 7 5 2 4 5 1 3 5 1 2 6 7 5 2 4 6 3 2 4 6 6 6 5 2 1 7 2 4 1 4 5 3 5 7 1 2 3 1 5 1 3 4 5 3 2 2 7 4 3 4 6 ...