Submission #1093657


Source Code Expand

Copy
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;

class Myon
{
    static Scanner cin;
    public Myon() { }
    public static int Main()
    {
        cin = new Scanner();
        new Myon().calc();
        return 0;
    }

    int N;
    long[] A;
    List<int>[] es;

    public void calc()
    {
        N = cin.nextInt();
        A = new long[N];
        for (int i = 0; i < N; i++)
        {
            A[i] = cin.nextLong();
        }
        es = new List<int>[N];
        for (int i = 0; i < N; i++)
        {
            es[i] = new List<int>();
        }

        for (int i = 0; i < N - 1; i++)
        {
            int a = cin.nextInt() - 1;
            int b = cin.nextInt() - 1;
            es[a].Add(b);
            es[b].Add(a);
        }

        check = new bool[N];
        win = new bool[N];
        for (int i = 0; i < N; i++)
        {
            if (dfs(i)) Console.Write((i + 1) + " ");
        }
        Console.WriteLine();
    }

    bool[] check;
    bool[] win;

    bool dfs(int now)
    {
        long T = A[now];
        check[now] = true;
        foreach (var next in es[now])
        {
            if (A[now] <= A[next]) continue;
            if (!dfs(next))
            {
                win[now] = true;
                return true;
            }
        }
        return false;
    }
    
}

class Scanner
{
    string[] s;
    int i;

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

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

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

    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 F - Tree Game
User chokudai
Language C# (Mono 4.6.2.0)
Score 1600
Code Size 2266 Byte
Status
Exec Time 35 ms
Memory 4312 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 sample1.txt, sample2.txt, sample3.txt
All 1600 / 1600 sample1.txt, sample2.txt, sample3.txt, in1.txt, in10.txt, in11.txt, in12.txt, in13.txt, in14.txt, in15.txt, in16.txt, in17.txt, in18.txt, in19.txt, in2.txt, in20.txt, in21.txt, in22.txt, in23.txt, in24.txt, in25.txt, in26.txt, in27.txt, in28.txt, in29.txt, in3.txt, in30.txt, in31.txt, in32.txt, in33.txt, in34.txt, in35.txt, in36.txt, in37.txt, in38.txt, in39.txt, in4.txt, in40.txt, in41.txt, in42.txt, in43.txt, in44.txt, in45.txt, in46.txt, in47.txt, in48.txt, in49.txt, in5.txt, in50.txt, in6.txt, in7.txt, in8.txt, in9.txt
Case Name Status Exec Time Memory
in1.txt 33 ms 4312 KB
in10.txt 32 ms 4312 KB
in11.txt 32 ms 4312 KB
in12.txt 24 ms 3160 KB
in13.txt 24 ms 3288 KB
in14.txt 33 ms 4312 KB
in15.txt 33 ms 4184 KB
in16.txt 33 ms 4312 KB
in17.txt 33 ms 4312 KB
in18.txt 33 ms 4312 KB
in19.txt 33 ms 4312 KB
in2.txt 33 ms 4312 KB
in20.txt 33 ms 4312 KB
in21.txt 34 ms 4312 KB
in22.txt 34 ms 4312 KB
in23.txt 34 ms 4312 KB
in24.txt 34 ms 4312 KB
in25.txt 34 ms 4312 KB
in26.txt 34 ms 4312 KB
in27.txt 34 ms 4312 KB
in28.txt 34 ms 4312 KB
in29.txt 35 ms 4312 KB
in3.txt 33 ms 4312 KB
in30.txt 34 ms 4312 KB
in31.txt 25 ms 4184 KB
in32.txt 25 ms 4184 KB
in33.txt 25 ms 4184 KB
in34.txt 25 ms 4184 KB
in35.txt 25 ms 4184 KB
in36.txt 20 ms 2776 KB
in37.txt 19 ms 2776 KB
in38.txt 19 ms 2776 KB
in39.txt 19 ms 2776 KB
in4.txt 33 ms 4312 KB
in40.txt 29 ms 3928 KB
in41.txt 30 ms 3928 KB
in42.txt 30 ms 3928 KB
in43.txt 30 ms 3928 KB
in44.txt 30 ms 3928 KB
in45.txt 24 ms 3928 KB
in46.txt 24 ms 3928 KB
in47.txt 31 ms 4056 KB
in48.txt 31 ms 4056 KB
in49.txt 31 ms 4056 KB
in5.txt 28 ms 3672 KB
in50.txt 32 ms 4056 KB
in6.txt 32 ms 4312 KB
in7.txt 33 ms 4312 KB
in8.txt 33 ms 4312 KB
in9.txt 33 ms 4312 KB
sample1.txt 20 ms 2776 KB
sample2.txt 20 ms 2776 KB
sample3.txt 19 ms 2776 KB