QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#109342#6367. Bad Worddo_while_trueWA 0ms3604kbC++141.0kb2023-05-28 16:51:442023-05-28 16:51:46

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-05-28 16:51:46]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3604kb
  • [2023-05-28 16:51:44]
  • 提交

answer

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
#include<vector>
typedef long long ll;
template <typename T> T Min(T x, T y) { return x < y ? x : y; }
template <typename T> T Max(T x, T y) { return x > y ? x : y; }
const int N = 200010;
int n, nxt[N][3], p[31], vis[31];
char ch[N];
std::vector< std::string > vec;
ll ans;
void check(int x) {
	int cur = 0;
	for(int i = 0; ; ++i) {
		cur = nxt[cur][p[i % x]];
		if(cur > n) {
			int ct = i / x;
			ans = Max(ans, 1ll * ct * ct * x);
			return ;
		}
	}
}
void dfs(int x) {
	if(x)
		check(x);
	for(int i = 0; i < 3; ++i)
		if(vis[i] < 2) {
			++vis[i];
			p[x] = i;
			dfs(x+1);
			--vis[i];
		}
}
void solve() {
	scanf("%d", &n);
	scanf("%s", ch+1);
	for(int j = 0; j < 3; ++j) nxt[n][j] = n+1;
	for(int i = n-1; i >= 0; --i) {
		for(int j = 0; j < 3; ++j)
			if(j + 'a' == ch[i+1]) nxt[i][j] = i + 1;
			else nxt[i][j] = nxt[i+1][j];
	}
	ans = 0;
	dfs(0);
	printf("%lld\n", ans);
} 
int main() {
	solve();return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3604kb

input:

7
abcdcba

output:

6

result:

wrong answer 1st numbers differ - expected: '2', found: '6'