結果
| 問題 |
No.8081 HQ9+
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-04-01 21:57:46 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 408 bytes |
| コンパイル時間 | 1,779 ms |
| コンパイル使用メモリ | 167,504 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-12-21 06:16:44 |
| 合計ジャッジ時間 | 3,268 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 RE * 1 |
| other | AC * 12 WA * 6 RE * 3 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
int N;
string S;
int main(){
cin>>N>>S;
int Q=count(S.begin(),S.end(),'Q');
int q=sqrt(Q);
if(q*q<Q)q++;
if(q*q>Q)q--;
if(q*q!=Q)return puts("-1"),0;
if(N%q)return puts("-1"),0;
for(int i=0;i<N/q;i++){
for(int j=0;j<q;j++){
if(S[i]!=S[i+j*(N/q)])return puts("-1"),0;
}
}
cout<<S.substr(0,N/q);
}