結果
問題 | No.1292 パタパタ三角形 |
ユーザー |
|
提出日時 | 2024-12-10 23:46:33 |
言語 | C# (.NET 8.0.404) |
結果 |
AC
|
実行時間 | 73 ms / 2,000 ms |
コード長 | 1,658 bytes |
コンパイル時間 | 9,356 ms |
コンパイル使用メモリ | 165,892 KB |
実行使用メモリ | 184,580 KB |
最終ジャッジ日時 | 2024-12-10 23:46:45 |
合計ジャッジ時間 | 11,527 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 14 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.csproj を復元しました (89 ms)。 MSBuild のバージョン 17.9.6+a4ecab324 (.NET) main -> /home/judge/data/code/bin/Release/net8.0/main.dll main -> /home/judge/data/code/bin/Release/net8.0/publish/
ソースコード
using System;using static System.Console;using System.Linq;using System.Collections.Generic;class Program{static int NN => int.Parse(ReadLine());static long[] NList => ReadLine().Split().Select(long.Parse).ToArray();public static void Main(){Solve();}static void Solve(){var s = ReadLine();var l = new char[] { 'a', ' ', 'b', 'c' };var x = 1000000;var y = 1000000;var set = new HashSet<long>{ Key(x, y) };var mx = new int[] { -1, 0, 0, 1 };var my = new int[] { 0, -1, 1, 0 };foreach (var si in s){var pos = Pos(l, si);x += mx[pos];y += my[pos];set.Add(Key(x, y));if (l[1] == ' '){if (pos == 0) (l[0], l[1], l[2], l[3]) = (l[2], l[3], l[1], l[0]);else if (pos == 2) (l[0], l[1], l[2], l[3]) = (l[0], l[2], l[1], l[3]);else (l[0], l[1], l[2], l[3]) = (l[3], l[0], l[1], l[2]);}else{if (pos == 0) (l[0], l[1], l[2], l[3]) = (l[1], l[2], l[3], l[0]);else if (pos == 1) (l[0], l[1], l[2], l[3]) = (l[0], l[2], l[1], l[3]);else (l[0], l[1], l[2], l[3]) = (l[3], l[2], l[0], l[1]);}}WriteLine(set.Count);}static int Pos(char[] a, char c){for (var i = 0; i < a.Length; ++i) if (a[i] == c) return i;return -1;}static long Key(int x, int y){return x * 10_000_000L + y;}}