結果
問題 | No.8081 HQ9+ |
ユーザー |
|
提出日時 | 2021-04-02 11:51:47 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 24 ms / 2,000 ms |
コード長 | 578 bytes |
コンパイル時間 | 4,180 ms |
コンパイル使用メモリ | 106,496 KB |
実行使用メモリ | 18,688 KB |
最終ジャッジ日時 | 2024-12-23 05:21:35 |
合計ジャッジ時間 | 2,564 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 21 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System;using System.Linq;class I{static void Main() => Console.WriteLine(Solve());static object Solve(){var n = int.Parse(Console.ReadLine());var s = Console.ReadLine();if (s.Contains('H')) return -1;if (!s.Contains('Q')) return -1;var qc = s.Count(c => c == 'Q');var rc = (int)Math.Round(Math.Sqrt(qc));if (rc * rc != qc) return -1;if (n % rc != 0) return -1;var sublength = n / rc;var sub = s[..sublength];for (int i = 0; i < rc; i++)if (s[(i * sublength)..((i + 1) * sublength)] != sub) return -1;return sub;}}