Submission #978144


Source Code Expand

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Threading;

using Pair = System.Collections.Generic.KeyValuePair<int, int>;

class Program
{
	public Program() { }

	static void Main(string[] args)
	{
		new Program().prog();
	}
	Scanner cin;
	const int MOD = 1000000007;
	const int INF = int.MaxValue - 10;
	const long INFL = long.MaxValue - 10;
	const double EPS = 1e-7;
	const double PI = 3.1415926536;

	int N;
	void prog()
	{
		cin = new Scanner();
		int[,] dir8 = new int[8, 2] { { -1, -1 }, { -1, 0 }, { -1, 1 }, { 0, -1 }, { 0, 1 }, { 1, -1 }, { 1, 0 }, { 1, 1 } };
		int[,] dir4 = new int[4, 2] { { -1, 0 }, { 0, -1 }, { 0, 1 }, { 1, 0 } };

		string str = cin.next();
		int num = 0, ret0, ret2;

		// num=0に対してやってみる
		for (int i = str.Length - 1; i >= 0; i--)
		{
			if (str[i] == '!')
			{
				num = (num == 0 ? 1 : 0);
			}
			else
			{
				num *= -1;
			}
		}
		ret0 = num;	// 0を入力したときの出力

		num = 2;
		// num=2に対してやってみる
		for (int i = str.Length - 1; i >= 0; i--)
		{
			if (str[i] == '!')
			{
				num = (num == 0 ? 1 : 0);
			}
			else
			{
				num *= -1;
			}
		}
		ret2 = num;	// 2を入力したときの出力

		if (ret0 == 0)	// !が偶数回
		{
			// ret2 == 0 はありえない
			if (ret2 == 1)
			{
				Console.WriteLine("!!");
			}
			else if (ret2 == -1)
			{
				Console.WriteLine("-!!");
			}
			else if (ret2 == 2)
			{
				Console.WriteLine("");
			}
			else if (ret2 == -2)
			{
				Console.WriteLine("-");
			}
		}
		else if (ret0 == 1)	// !が奇数回
		{
			// ret2 == 0 しかありえない
			Console.WriteLine("!");
		}
		else if(ret0 == -1)	// !が奇数回
		{
			// ret2 == 0 しかありえない
			Console.WriteLine("-!");
		}
	}

	public static int Compare(Pair x, Pair y)
	{
		if (x.Value == y.Value) return y.Key - x.Key;
		return x.Value - y.Value;
	}
}

class Scanner
{
	string[] s;
	int i;

	char[] cs = new char[] { ' ' };

	public Scanner()
	{
		s = new string[0];
		i = 0;
	}

	public string next()
	{
		if (i < s.Length) return s[i++];
		string st = Console.ReadLine();
		while (st == "") st = Console.ReadLine();
		s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
		i = 0;
		return next();
	}

	public int nextInt()
	{
		return int.Parse(next());
	}

	public long nextLong()
	{
		return long.Parse(next());
	}

	public double nextDouble()
	{
		return double.Parse(next());
	}
}

Submission Info

Submission Time
Task E - ショートコーディング
User furuya1223
Language C# (Mono 3.2.1.0)
Score 100
Code Size 2606 Byte
Status AC
Exec Time 95 ms
Memory 8604 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 100 / 100
Status
AC × 3
AC × 32
Set Name Test Cases
Sample sample-01.txt, sample-02.txt, sample-03.txt
All sample-01.txt, sample-02.txt, sample-03.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 01-11.txt, 01-12.txt, 01-13.txt, 01-14.txt, 01-15.txt, 01-16.txt, 01-17.txt, 01-18.txt, 01-19.txt, 01-20.txt, 01-21.txt, 01-22.txt, 01-23.txt, 01-24.txt, 01-25.txt, 01-26.txt, 01-27.txt, 01-28.txt, 01-29.txt
Case Name Status Exec Time Memory
01-01.txt AC 95 ms 8584 KB
01-02.txt AC 73 ms 8484 KB
01-03.txt AC 75 ms 8480 KB
01-04.txt AC 88 ms 8492 KB
01-05.txt AC 74 ms 8568 KB
01-06.txt AC 75 ms 8472 KB
01-07.txt AC 74 ms 8484 KB
01-08.txt AC 78 ms 8480 KB
01-09.txt AC 75 ms 8488 KB
01-10.txt AC 76 ms 8584 KB
01-11.txt AC 75 ms 8596 KB
01-12.txt AC 75 ms 8500 KB
01-13.txt AC 74 ms 8600 KB
01-14.txt AC 76 ms 8556 KB
01-15.txt AC 76 ms 8492 KB
01-16.txt AC 75 ms 8596 KB
01-17.txt AC 73 ms 8596 KB
01-18.txt AC 76 ms 8484 KB
01-19.txt AC 75 ms 8600 KB
01-20.txt AC 75 ms 8592 KB
01-21.txt AC 77 ms 8500 KB
01-22.txt AC 76 ms 8596 KB
01-23.txt AC 72 ms 8580 KB
01-24.txt AC 75 ms 8596 KB
01-25.txt AC 74 ms 8584 KB
01-26.txt AC 74 ms 8544 KB
01-27.txt AC 73 ms 8584 KB
01-28.txt AC 75 ms 8552 KB
01-29.txt AC 74 ms 8484 KB
sample-01.txt AC 75 ms 8596 KB
sample-02.txt AC 75 ms 8604 KB
sample-03.txt AC 77 ms 8596 KB