QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#248404 | #6442. Secret of Tianqiu Valley | Determinant# | RE | 0ms | 3732kb | C++14 | 1.4kb | 2023-11-11 18:59:55 | 2023-11-11 18:59:55 |
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<100;t++){
for(int i=0;i<n;i++)if(x[i]==0&&y[i]==1)op(i);
}
for(int t=0;t<100;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;
}
signed main(){
int t;cin>>t;
while(t--)solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3732kb
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: -100
Runtime Error
input:
7 3 000 3 100 3 010 3 110 3 001 3 101 3 011