結果

問題 No.3081 HQ9+
ユーザー %20%20
提出日時 2021-03-10 10:10:02
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 370 bytes
コンパイル時間 2,085 ms
コンパイル使用メモリ 195,504 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-20 13:20:34
合計ジャッジ時間 2,904 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

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