結果

問題 No.8081 HQ9+
ユーザー %20
提出日時 2021-03-10 10:10:02
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 370 bytes
コンパイル時間 1,938 ms
コンパイル使用メモリ 193,464 KB
最終ジャッジ日時 2025-01-19 13:11:27
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 15 WA * 6
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

int main(){cin.tie(0);ios::sync_with_stdio(false);
	int N;cin>>N;
	string S;cin>>S;
	int Q=count(S.begin(),S.end(),'Q');
	int K=sqrt(Q);
	if(Q>0&&K*K==Q&&N%K==0){
		bool ok=true;
		for(int i=0;i+N/K<N;++i){
			ok&=S[i]==S[i+N/K];
		}
		if(ok){
			cout<<S.substr(0,N/K)<<"\n";
			return 0;
		}
	}
	cout<<"-1\n";
	return 0;
}
0