QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#256330#6299. Binary StringSATSKYWA 131ms3576kbC++201.4kb2023-11-18 18:34:322023-11-18 18:34:33

Judging History

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

  • [2023-11-18 18:34:33]
  • 评测
  • 测评结果:WA
  • 用时:131ms
  • 内存:3576kb
  • [2023-11-18 18:34:32]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;using ll=long long;const int M=998244353;const double eps=1e-10,inf=1e30;
struct node{int v,l,r;};
struct S
{
	vector<node>arr;string s;
	vector<int>l,r,cov;
	bool chk(int L,int segc)
	{
		if(L%segc)return 0;int B=L/segc;
		for(int j=1;j<segc;j++)if(s.substr(0,B)!=s.substr(B*j,B))return 0;return 1;
	}
	void solve()
	{
		cin>>s;int n=s.length(),res=0;l.resize(n);r.resize(n);cov.resize(n,0);queue<pair<int,int>>Q;
		for(int i=0;i<n;i++){l[i]=(i+n-1)%n,r[i]=(i+1)%n;if(s[i]=='0'&&s[(i+1)%n]=='1')Q.push({i,0});}
		for(;!Q.empty();Q.pop())
		{
			int L=Q.front().first,val=Q.front().second,R=r[L],LL=l[L],RR=r[R];
			res=val;cov[L]=cov[R]=1;if(LL==L)continue;
			r[LL]=RR,l[RR]=LL;if(s[LL]=='0'&&s[RR]=='1')Q.push({LL,val+1});
		}
		int p=0;for(int i=0;i<n;i++)if(!cov[i])p=i;for(int i=p,sw=0;i<p+n;i++)if(cov[i%n])s[i%n]='0'+sw,sw^=1;
		//cout<<res<<"|"<<s<<'\n';
		int lft=n,segc=1;
		for(int i=2;i*i<=lft;i++)if(lft%i==0)
		{
			int L=n;while(chk(L,i))L/=i,segc*=i;
			while(lft%i==0)lft/=i;
		}
		if(chk(n,lft))segc*=lft;
		//cout<<segc<<"|\n";
		cout<<res+n/segc<<'\n';
	}
};
void precal()
{
	
}
int main()
{
	//freopen("1.in","r",stdin);
	cout<<fixed<<setprecision(12);
	ios::sync_with_stdio(0);cin.tie(0);precal();
	int t=1;cin>>t;
	//clock_t a=clock();
	while(t--){S SS;SS.solve();}
	//cout<<"Time:"<<double(clock()-a)<<'\n';
}

详细

Test #1:

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

input:

3
1
001001
0001111

output:

1
3
9

result:

ok 3 number(s): "1 3 9"

Test #2:

score: -100
Wrong Answer
time: 131ms
memory: 3576kb

input:

262144
000000000000000000
100000000000000000
010000000000000000
110000000000000000
001000000000000000
101000000000000000
011000000000000000
111000000000000000
000100000000000000
100100000000000000
010100000000000000
110100000000000000
001100000000000000
101100000000000000
011100000000000000
11110000...

output:

1
18
18
19
18
18
19
20
18
18
18
19
19
19
20
21
18
18
18
19
18
18
19
20
19
19
19
20
20
20
21
22
18
18
18
19
18
18
19
20
18
18
18
19
19
19
20
21
19
19
19
19
19
19
20
21
20
20
20
21
21
21
22
23
18
18
18
19
18
18
19
20
18
18
18
19
19
19
20
21
18
18
18
19
18
18
19
20
19
19
19
20
20
20
21
22
19
19
19
19
1...

result:

wrong answer 12th numbers differ - expected: '20', found: '19'