結果
| 問題 |
No.3110 Like CPCTF?
|
| コンテスト | |
| ユーザー |
bluemegane
|
| 提出日時 | 2025-04-19 13:32:19 |
| 言語 | C# (.NET 8.0.404) |
| 結果 |
AC
|
| 実行時間 | 54 ms / 2,000 ms |
| コード長 | 1,585 bytes |
| コンパイル時間 | 23,185 ms |
| コンパイル使用メモリ | 173,812 KB |
| 実行使用メモリ | 187,952 KB |
| 最終ジャッジ日時 | 2025-04-19 13:32:45 |
| 合計ジャッジ時間 | 19,244 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 16 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.csproj を復元しました (107 ミリ秒)。 main -> /home/judge/data/code/bin/Release/net8.0/main.dll main -> /home/judge/data/code/bin/Release/net8.0/publish/
ソースコード
using System.Collections.Generic;
using System;
public class Hello
{
static void Main()
{
var n = int.Parse(Console.ReadLine().Trim());
var s = Console.ReadLine().Trim();
getAns(n, s);
}
static int check2(int n, int[] t, int x, int y, int p)
{
var res = 0;
for (int i = p; i < n - 1; i++)
{
for (int j = i + 1; j < n; j++)
{
if (t[i] == t[j]) continue;
if (t[i] != x && t[i] != y && t[j] != x && t[j] != y) res++;
}
}
return res;
}
static int check(int n, int[] t, int L, int r)
{
var res = 0;
for (int i = L + 1; i < r; i++)
{
if (t[i] != t[L]) res += check2(n, t, t[L], t[i], r + 1);
}
return res;
}
static void getAns(int n, string s)
{
var t = new int[n];
var aa = new List<int>[26];
for (int i = 0; i < 26; i++) aa[i] = new List<int>();
for (int i = 0; i < n; i++)
{
var w = s[i] - 'A';
t[i] = w;
aa[w].Add(i);
}
var ans = 0;
for (int i = 0; i < 26; i++)
{
var aac = aa[i].Count;
if (aac > 1)
{
for (int j = 0; j < aac - 1; j++)
{
for (int k = j + 1; k < aac; k++)
{
ans += check(n, t, aa[i][j], aa[i][k]);
}
}
}
}
Console.WriteLine(ans);
}
}
bluemegane