結果

問題 No.197 手品
ユーザー nuwasogi
提出日時 2015-11-28 18:43:28
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 30 ms / 1,000 ms
コード長 3,412 bytes
コンパイル時間 3,265 ms
コンパイル使用メモリ 117,076 KB
実行使用メモリ 25,712 KB
最終ジャッジ日時 2024-07-20 03:44:37
合計ジャッジ時間 4,239 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 43
権限があれば一括ダウンロードができます
コンパイルメッセージ
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.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections;

namespace Tejina_CS
{
    class Program
    {
        static void Main(string[] args)
        {
            Solution sol = new Solution();
            sol.Solve();
        }

    }

    class Solution
    {
        bool[] Cba = new bool[3]; // true コインあり, false コイン無し
        bool[] Caa = new bool[3];

        static bool[] b4 = { false, true, false };
        static bool[] b5 = { true, false, true };

        int N;
        int nb = 0, na = 0;
        string s = "SUCCESS", f = "FAILURE";

        public void Solve()
        {
            if (nb != na)
            {
                Console.WriteLine(s);
            }
            else
            {
                switch (N)
                {
                    case 0:
                        if (BEquals(Cba, Caa)) Console.WriteLine(f);
                        else Console.WriteLine(s);
                        break;
                    case 1:
                        bool b4r = BEquals(b4, BAnd(Cba, Caa));
                        bool b5r = BEquals(b5, BOr(Cba,Caa));
                        if (b4r || b5r) Console.WriteLine(s);
                        else Console.WriteLine(f);
                        break;
                    default:
                        Console.WriteLine(f);
                        break;
                }
            }
        }

        public Solution()
        {
            string Sbefore = rs();
            N = ri();
            string Safter = rs();

            for (int i = 0; i < Cba.Length; i++)
            {
                if (Sbefore[i] == 'o')
                {
                    Cba[i] = true;
                    nb++;
                }
            }
            for (int i = 0; i < Caa.Length; i++)
            {
                if (Safter[i] == 'o')
                {
                    Caa[i] = true;
                    na++;
                }
            }
        }

        public static bool BEquals(bool[] x, bool[] y)
        {
            for (int i = 0; i < x.Length; i++)
                if (x[i] != y[i]) return false;
            return true;
        }
        public static bool[] BAnd(bool[] x, bool[] y)
        {
            bool[] ret = new bool[3];
            for(int i=0; i<ret.Length; i++)
            {
                ret[i] = x[i] & y[i];
            }
            return ret;
        }
        public static bool[] BOr(bool[] x, bool[] y)
        {
            bool[] ret = new bool[3];
            for (int i = 0; i < ret.Length; i++)
            {
                ret[i] = x[i] | y[i];
            }
            return ret;
        }

        static String rs() { return Console.ReadLine(); }
        static int ri() { return int.Parse(Console.ReadLine()); }
        static long rl() { return long.Parse(Console.ReadLine()); }
        static double rd() { return double.Parse(Console.ReadLine()); }
        static String[] rsa() { return Console.ReadLine().Split(' '); }
        static int[] ria() { return Console.ReadLine().Split(' ').Select(e => int.Parse(e)).ToArray(); }
        static long[] rla() { return Console.ReadLine().Split(' ').Select(e => long.Parse(e)).ToArray(); }
        static double[] rda() { return Console.ReadLine().Split(' ').Select(e => double.Parse(e)).ToArray(); }
    }
}
0