結果

問題 No.197 手品
ユーザー hogekihogeki
提出日時 2016-08-27 23:32:31
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 53 ms / 1,000 ms
コード長 1,290 bytes
コンパイル時間 1,874 ms
コンパイル使用メモリ 102,796 KB
実行使用メモリ 22,908 KB
最終ジャッジ日時 2023-09-27 09:41:56
合計ジャッジ時間 5,770 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 48 ms
20,728 KB
testcase_01 AC 48 ms
22,672 KB
testcase_02 AC 48 ms
20,684 KB
testcase_03 AC 50 ms
20,676 KB
testcase_04 AC 52 ms
22,908 KB
testcase_05 AC 48 ms
20,648 KB
testcase_06 AC 47 ms
20,796 KB
testcase_07 AC 48 ms
20,736 KB
testcase_08 AC 49 ms
20,668 KB
testcase_09 AC 49 ms
20,752 KB
testcase_10 AC 48 ms
20,624 KB
testcase_11 AC 48 ms
18,636 KB
testcase_12 AC 49 ms
22,720 KB
testcase_13 AC 47 ms
20,664 KB
testcase_14 AC 50 ms
20,756 KB
testcase_15 AC 51 ms
20,780 KB
testcase_16 AC 50 ms
20,700 KB
testcase_17 AC 51 ms
22,688 KB
testcase_18 AC 52 ms
22,856 KB
testcase_19 AC 50 ms
20,664 KB
testcase_20 AC 48 ms
20,620 KB
testcase_21 AC 50 ms
20,684 KB
testcase_22 AC 49 ms
20,704 KB
testcase_23 AC 49 ms
22,700 KB
testcase_24 AC 49 ms
20,608 KB
testcase_25 AC 50 ms
20,664 KB
testcase_26 AC 49 ms
20,684 KB
testcase_27 AC 50 ms
20,792 KB
testcase_28 AC 48 ms
20,652 KB
testcase_29 AC 50 ms
20,844 KB
testcase_30 AC 50 ms
22,708 KB
testcase_31 AC 51 ms
18,736 KB
testcase_32 AC 51 ms
22,792 KB
testcase_33 AC 53 ms
22,784 KB
testcase_34 AC 49 ms
20,756 KB
testcase_35 AC 48 ms
22,728 KB
testcase_36 AC 48 ms
22,716 KB
testcase_37 AC 48 ms
20,784 KB
testcase_38 AC 50 ms
22,656 KB
testcase_39 AC 48 ms
18,716 KB
testcase_40 AC 50 ms
20,668 KB
testcase_41 AC 48 ms
20,768 KB
testcase_42 AC 50 ms
20,768 KB
testcase_43 AC 49 ms
22,692 KB
testcase_44 AC 50 ms
20,732 KB
testcase_45 AC 51 ms
20,664 KB
testcase_46 AC 50 ms
18,820 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;

class Magic
{
	static void Main(String[] args)
	{
		String Sbefore;
		long N;
		String Safter;

		Sbefore = Console.ReadLine();
		N = long.Parse(Console.ReadLine());
		Safter = Console.ReadLine();

		int cb = CountCoins(Sbefore);
		int ca = CountCoins(Safter);

		if(cb != ca)
		{
			Console.WriteLine("SUCCESS");
			return;
		}
		if(cb == 0 || cb == 3)
		{
			Console.WriteLine("FAILURE");
			return;
		}
		if(N >= 2)
		{
			Console.WriteLine("FAILURE");
			return;
		}
		if(N == 1)
		{
			if(SwapCmp(Sbefore, Safter))
			{
				Console.WriteLine("FAILURE");
				return;
			}
			else
			{
				Console.WriteLine("SUCCESS");
				return;
			}
		}
		if(N == 0)
		{
			if(Sbefore == Safter)
			{
				Console.WriteLine("FAILURE");
				return;
			}
			else
			{
				Console.WriteLine("SUCCESS");
				return;
			}
		}

	}

	static int CountCoins(String S)
	{
		int ret = 0;

		foreach(char c in S)
		{
			if(c == 'o')
				ret++;
		}
		return ret;
	}

	static bool SwapCmp(String b, String a)
	{
		char[] buff = new char[3];
		
		buff[0] = b[1];
		buff[1] = b[0];
		buff[2] = b[2];

		String s1 = new String(buff);
		if(s1 == a)
			return true;

		buff[0] = b[0];
		buff[1] = b[2];
		buff[2] = b[1];

		String s2 = new String(buff);
		if(s2 == a)
			return true;
		return false;
	}
}
0