QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#724275#6299. Binary StringluobotianleTL 870ms3632kbC++14543b2024-11-08 11:33:562024-11-08 11:33:59

Judging History

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

  • [2024-11-08 11:33:59]
  • 评测
  • 测评结果:TL
  • 用时:870ms
  • 内存:3632kb
  • [2024-11-08 11:33:56]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int T;
string s,t;
int n;
map<string,int> vis;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	cin>>T;
	while(cin>>s){
		vis.clear();
//		cin>>s;
		s=' '+s;
		n=s.size()-1;
		while(!vis[s]){
//			cout<<s<<" -> ";
			vis[s]=1;
			t=s;
			for(int i=1;i<n;i++){
				if(s[i]=='0'&&s[i+1]=='1')swap(t[i],t[i+1]);
			}
			if(s[n]=='0'&&s[1]=='1')swap(t[1],t[n]);
			s=t;
//			cout<<s<<"\n";
		}
		cout<<vis.size()<<"\n";
	}
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3492kb

input:

3
1
001001
0001111

output:

1
3
9

result:

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

Test #2:

score: 0
Accepted
time: 870ms
memory: 3632kb

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
20
19
19
20
21
18
18
18
19
18
18
20
21
19
19
19
21
20
20
21
22
18
18
18
19
18
18
19
21
18
18
18
21
20
20
21
22
19
19
19
19
19
19
21
22
20
20
20
22
21
21
22
23
18
18
18
19
18
18
19
20
18
18
18
20
19
19
21
22
18
18
18
19
18
18
21
22
20
20
20
22
21
21
22
23
19
19
19
19
1...

result:

ok 262144 numbers

Test #3:

score: -100
Time Limit Exceeded

input:

524288
0000000000000000000
1000000000000000000
0100000000000000000
1100000000000000000
0010000000000000000
1010000000000000000
0110000000000000000
1110000000000000000
0001000000000000000
1001000000000000000
0101000000000000000
1101000000000000000
0011000000000000000
1011000000000000000
0111000000000...

output:

1
19
19
20
19
19
20
21
19
19
19
21
20
20
21
22
19
19
19
20
19
19
21
22
20
20
20
22
21
21
22
23
19
19
19
20
19
19
20
22
19
19
19
22
21
21
22
23
20
20
20
20
20
20
22
23
21
21
21
23
22
22
23
24
19
19
19
20
19
19
20
21
19
19
19
21
20
20
22
23
19
19
19
20
19
19
22
23
21
21
21
23
22
22
23
24
20
20
20
20
2...

result: