QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#248407#6442. Secret of Tianqiu ValleychengchRE 1ms3384kbC++141.0kb2023-11-11 19:00:422023-11-11 19:00:43

Judging History

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

  • [2023-11-11 19:00:43]
  • 评测
  • 测评结果:RE
  • 用时:1ms
  • 内存:3384kb
  • [2023-11-11 19:00:42]
  • 提交

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;
}

signed main(){
	int t;cin>>t;
	while(t--)solve();
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 3384kb

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

output:


result: