結果
| 問題 |
No.24 数当てゲーム
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-12-16 22:23:20 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 33 ms / 5,000 ms |
| コード長 | 2,206 bytes |
| コンパイル時間 | 1,078 ms |
| コンパイル使用メモリ | 109,184 KB |
| 実行使用メモリ | 19,456 KB |
| 最終ジャッジ日時 | 2024-12-14 21:55:27 |
| 合計ジャッジ時間 | 1,836 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 10 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
namespace yukicore
{
//this algorithm think by claclator
class Element
{
public int[] nums;
public Element(int[] nums) => this.nums = nums;
public Element(Element e) => this.nums = e.nums;
public static Element operator -(Element a, Element b)
{
var rtn = new List<int>();
foreach (var num in a.nums)
{
if (b.nums.All(x => x != num))
rtn.Add(num);
}
return new Element(rtn.ToArray());
}
public static Element operator +(Element a, Element b)
{
var rtn = new List<int>();
rtn.AddRange(a.nums);
rtn.AddRange(b.nums);
return new Element(rtn.Distinct().ToArray());
}
public static Element operator *(Element a, Element b)
{
var rtn = new List<int>();
foreach (var num in a.nums)
{
if (b.nums.Contains(num))
rtn.Add(num);
}
return new Element(rtn.ToArray());
}
}
internal class Program
{
private static void Main(string[] args)
{
Element mother = new Element(Enumerable.Range(0, 10).ToArray());
Element rtn = new Element(Enumerable.Range(0, 10).ToArray());
Console.ReadLine();
while (true)
{
var tmp = Console.ReadLine();
if (tmp == null || tmp == "") break;
var spl = tmp.Split(' ');
var inputs = spl.Take(4).Select(x => int.Parse(x)).ToArray();
var flag = spl.Last() == "YES" ? true : false;
Element input;
if (flag)
input = new Element(inputs);
else
input = new Element(mother - new Element(inputs));
rtn *= input;
}
Console.WriteLine(
rtn.nums[0]);
}
}
}