結果

問題 No.3081 HQ9+
ユーザー さかぽんさかぽん
提出日時 2021-04-02 11:51:47
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 59 ms / 2,000 ms
コード長 578 bytes
コンパイル時間 2,372 ms
コンパイル使用メモリ 106,492 KB
実行使用メモリ 23,664 KB
最終ジャッジ日時 2023-08-24 19:56:33
合計ジャッジ時間 4,702 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 57 ms
21,524 KB
testcase_01 AC 57 ms
21,580 KB
testcase_02 AC 57 ms
21,756 KB
testcase_03 AC 56 ms
21,668 KB
testcase_04 AC 56 ms
21,680 KB
testcase_05 AC 57 ms
23,664 KB
testcase_06 AC 57 ms
19,548 KB
testcase_07 AC 57 ms
21,540 KB
testcase_08 AC 57 ms
21,732 KB
testcase_09 AC 57 ms
21,628 KB
testcase_10 AC 56 ms
19,588 KB
testcase_11 AC 56 ms
19,528 KB
testcase_12 AC 57 ms
23,612 KB
testcase_13 AC 57 ms
23,612 KB
testcase_14 AC 59 ms
21,544 KB
testcase_15 AC 57 ms
21,676 KB
testcase_16 AC 59 ms
23,540 KB
testcase_17 AC 58 ms
23,472 KB
testcase_18 AC 58 ms
21,612 KB
testcase_19 AC 58 ms
21,596 KB
testcase_20 AC 58 ms
21,504 KB
testcase_21 AC 59 ms
23,608 KB
testcase_22 AC 59 ms
23,508 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

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;
	}
}
0