結果
問題 | No.8081 HQ9+ |
ユーザー |
|
提出日時 | 2021-04-01 22:58:48 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 531 bytes |
コンパイル時間 | 1,759 ms |
コンパイル使用メモリ | 168,260 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-12-21 07:03:30 |
合計ジャッジ時間 | 2,852 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 18 WA * 3 |
ソースコード
#include<bits/stdc++.h> using namespace std; int N; string S; int my_sqrt(int N){ int a=0; while(a*a<N)a++; return a; } int main(){ cin>>N>>S; int Q=count(S.begin(),S.end(),'Q'); if(Q==0)return puts("-1"),0; int q=my_sqrt(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*q])return puts("-1"),0; } } if(count(S.begin(),S.end(),'H'))return puts("-1"),0; cout<<S.substr(0,N/q); }