結果
| 問題 |
No.3110 Like CPCTF?
|
| コンテスト | |
| ユーザー |
bluemegane
|
| 提出日時 | 2025-04-19 14:00:28 |
| 言語 | C# (.NET 8.0.404) |
| 結果 |
AC
|
| 実行時間 | 350 ms / 2,000 ms |
| コード長 | 1,591 bytes |
| コンパイル時間 | 10,640 ms |
| コンパイル使用メモリ | 172,268 KB |
| 実行使用メモリ | 214,344 KB |
| 最終ジャッジ日時 | 2025-04-19 14:00:52 |
| 合計ジャッジ時間 | 14,672 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 16 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.csproj を復元しました (90 ミリ秒)。 /home/judge/data/code/Main.cs(5,21): warning CS8981: 型名 'combi' には、小文字の ASCII 文字のみが含まれています。このような名前は、プログラミング言語用に予約されている可能性があります。 [/home/judge/data/code/main.csproj] main -> /home/judge/data/code/bin/Release/net8.0/main.dll main -> /home/judge/data/code/bin/Release/net8.0/publish/
ソースコード
using System.Linq;
using System.Collections.Generic;
using System;
public static class combi
{
public static IEnumerable<IEnumerable<T>> Comb<T>(this IEnumerable<T> items, int r)
{
if (r == 0)
{
yield return Enumerable.Empty<T>();
}
else
{
var i = 1;
foreach (var x in items)
{
var xs = items.Skip(i);
foreach (var c in Comb(xs, r - 1))
yield return c.Before(x);
i++;
}
}
}
public static IEnumerable<T> Before<T>(this IEnumerable<T> items, T first)
{
yield return first;
foreach (var i in items)
yield return i;
}
}
public class Hello
{
static void Main()
{
var n = int.Parse(Console.ReadLine().Trim());
var s = Console.ReadLine().Trim();
getAns(n, s);
}
static bool check(int[] a, string s)
{
if (s[a[0]] != s[a[2]]) return false;
if (s[a[0]] == s[a[1]]) return false;
if (s[a[0]] == s[a[3]]) return false;
if (s[a[0]] == s[a[4]]) return false;
if (s[a[1]] == s[a[3]]) return false;
if (s[a[3]] == s[a[4]]) return false;
if (s[a[4]] == s[a[1]]) return false;
return true;
}
static void getAns(int n, string s)
{
var a = Enumerable.Range(0, n).Comb(5);
var ans = 0;
foreach (var x in a)
{
var y = x.ToArray();
if (check(y, s)) ans++;
}
Console.WriteLine(ans);
}
}
bluemegane