結果
| 問題 |
No.556 仁義なきサルたち
|
| コンテスト | |
| ユーザー |
Risen
|
| 提出日時 | 2017-08-12 00:47:44 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,416 bytes |
| コンパイル時間 | 1,012 ms |
| コンパイル使用メモリ | 115,560 KB |
| 実行使用メモリ | 31,892 KB |
| 最終ジャッジ日時 | 2024-10-12 22:39:11 |
| 合計ジャッジ時間 | 10,394 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 18 TLE * 1 -- * 3 |
コンパイルメッセージ
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.Linq;
class Solution
{
static void Main()
{
var vals = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
var n = vals[0];
var m = vals[1];
var battles = new int[m][];
for (int i = 0; i < m; i++)
{
battles[i] = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
}
var team = Enumerable.Range(0, n + 1).ToArray();
foreach (var battle in battles)
{
var boss = battle.Select(i => team[i]).ToArray();
var win = boss[0];
var lose = boss[1];
if (win == lose)
{
continue;
}
var counts = Enumerable.Range(0, 2).Select(i => team.Count(t => t == boss[i])).ToArray();
if (counts[0] < counts[1])
{
win = boss[1];
lose = boss[0];
}
else if (counts[0] == counts[1] && boss[0] > boss[1])
{
win = boss[1];
lose = boss[0];
}
for (int i = 1; i <= n; i++)
{
if (team[i] == lose)
{
team[i] = win;
}
}
}
foreach (var t in team.Skip(1))
{
Console.WriteLine(t);
}
}
}
Risen