QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#445361#8521. Pattern Search IIucup-team3695#WA 0ms3736kbC++20754b2024-06-16 01:34:102024-06-16 01:34:10

Judging History

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

  • [2024-06-16 01:34:10]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3736kb
  • [2024-06-16 01:34:10]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

int main()
{
	long long a = 0, b = 1;
	string	  s;
	cin >> s;
	long long	ans = (int)size(s);
	deque<char> S(begin(s), end(s)), T;
	for (;;)
	{
		tie(a, b) = pair{b, a + b};
		if (S.size() == 1)
			break;
		if (S.front() == 'b')
			S.push_front('a');
		if (S.back() == 'a')
			S.pop_back();
		if (S.size() == 1)
			break;

		T.clear();
		for (int i = 0; i < (int)size(S);)
		{
			if (S[i] == 'a')
			{
				if (i < (int)size(S) - 1 && S[i + 1] == 'b')
				{
					T.push_back('a');
					i += 2;
				}
				else
				{
					T.push_back('b');
					i++;
				}
			}
			else
			{
				T.push_back('a');
				i++;
				ans += b;
			}
		}
		S.swap(T);
	}
	cout << ans;
}

詳細信息

Test #1:

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

input:

aabbaab

output:

8

result:

ok 1 number(s): "8"

Test #2:

score: 0
Accepted
time: 0ms
memory: 3524kb

input:

a

output:

1

result:

ok 1 number(s): "1"

Test #3:

score: 0
Accepted
time: 0ms
memory: 3596kb

input:

b

output:

1

result:

ok 1 number(s): "1"

Test #4:

score: 0
Accepted
time: 0ms
memory: 3456kb

input:

aa

output:

2

result:

ok 1 number(s): "2"

Test #5:

score: 0
Accepted
time: 0ms
memory: 3736kb

input:

bb

output:

3

result:

ok 1 number(s): "3"

Test #6:

score: 0
Accepted
time: 0ms
memory: 3516kb

input:

ab

output:

2

result:

ok 1 number(s): "2"

Test #7:

score: 0
Accepted
time: 0ms
memory: 3580kb

input:

ba

output:

2

result:

ok 1 number(s): "2"

Test #8:

score: -100
Wrong Answer
time: 0ms
memory: 3524kb

input:

bbba

output:

9

result:

wrong answer 1st numbers differ - expected: '7', found: '9'