結果

問題 No.938 賢人を探せ
ユーザー bluemeganebluemegane
提出日時 2019-12-04 21:02:51
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 144 ms / 2,000 ms
コード長 829 bytes
コンパイル時間 3,239 ms
コンパイル使用メモリ 107,048 KB
実行使用メモリ 30,904 KB
最終ジャッジ日時 2023-08-21 03:34:14
合計ジャッジ時間 6,336 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 144 ms
28,944 KB
testcase_01 AC 66 ms
22,456 KB
testcase_02 AC 65 ms
20,468 KB
testcase_03 AC 64 ms
22,516 KB
testcase_04 AC 64 ms
20,580 KB
testcase_05 AC 64 ms
22,608 KB
testcase_06 AC 64 ms
24,500 KB
testcase_07 AC 64 ms
22,480 KB
testcase_08 AC 88 ms
25,004 KB
testcase_09 AC 87 ms
24,888 KB
testcase_10 AC 64 ms
22,608 KB
testcase_11 AC 94 ms
27,932 KB
testcase_12 AC 91 ms
28,256 KB
testcase_13 AC 90 ms
26,056 KB
testcase_14 AC 90 ms
26,092 KB
testcase_15 AC 92 ms
26,136 KB
testcase_16 AC 90 ms
24,012 KB
testcase_17 AC 91 ms
26,116 KB
testcase_18 AC 92 ms
26,068 KB
testcase_19 AC 91 ms
28,168 KB
testcase_20 AC 91 ms
26,064 KB
testcase_21 AC 90 ms
28,048 KB
testcase_22 AC 139 ms
30,904 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System.Linq;
using System.Collections.Generic;
using System;

public class Hello
{
    static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        var c = new HashSet<string>();
        var ok = new HashSet<string>();
        var w = new List<string>();
        for (int i = 0; i < n; i++)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var a = line[0];
            var b = line[1];
            w.Add(b);
            if (c.Add(a))
            c.Add(a);
            ok.Remove(a);
            if (c.Add(b))
            {
                ok.Add(b);
                c.Remove(b);
            }
        }
        var w2 = w.Distinct().ToList();
        for (int i = 0; i < w2.Count(); i++)
            if (ok.Contains(w2[i])) Console.WriteLine(w2[i]);
    }
}

0