提出 #538996


ソースコード 拡げる

using LIB;
using System;
using System.Linq;
using System.Text;
using System.Numerics;
using System.Collections.Generic;

class Program
{
    public static IO IO = new IO();
    static void Main(string[] args)
    {
        int[] t = IO.INT(' ');
        string buf = IO.STRING();
        BigInteger k = BigInteger.Parse(buf);
        int n = t[0];
        int a = t[1] - 1;
        int[] b = IO.INT(' ');
        int loop = 0;
        Dictionary<int, int> path = new Dictionary<int, int>();
        int i = a;
        int c = 1;
        while (true)
        {
            if (path.ContainsKey(i)) { loop = c - path[i] + 1; break; }
            else { path[i] = c; }
            i = b[i] - 1;
            k--;
            c++;
            if (k == 0) { break; }
        }
        if (loop > 0) { k %= loop; }
        while (k > 0) { i = b[i] - 1; k--; }
        IO.WRITE(i + 1);
        IO.FLUSH();
    }
}

namespace LIB
{
    public class IO
    {
        private const int WMAX = 1000;
        private StringBuilder S = new StringBuilder();
        private T R<T>(Func<string, T> f) { return f(Console.ReadLine()); }
        private T[] R<T>(Func<string, T> f, char c) { return STRING().Split(c).Select(f).ToArray(); }
        private T[] R<T>(Func<string, T> f, int l) { T[] r = new T[l]; for (int i = 0; i < l; i++) { r[i] = R(f); } return r; }
        private T[][] R<T>(Func<string, T> f, int l, char c) { T[][] r = new T[l][]; for (int i = 0; i < l; i++) { r[i] = R<T>(f, c); } return r; }
        private void W<T>(Func<T, string> f, T v, bool lf = true) { S.Append(f(v)); if (lf == true) { S.Append('\n'); } if (S.Length >= WMAX) { FLUSH(); } }
        public string STRING() { return R(s => s); }
        public string[] STRING(char c) { return R(s => s, c); }
        public string[] STRING(int l) { return R(s => s, l); }
        public string[][] STRING(int l, char c) { return R(s => s, l, c); }
        public int INT() { return R(int.Parse); }
        public int[] INT(char c) { return R(int.Parse, c); }
        public int[] INT(int l) { return R(int.Parse, l); }
        public int[][] INT(int l, char c) { return R(int.Parse, l, c); }
        public long LONG() { return R(long.Parse); }
        public long[] LONG(char c) { return R(long.Parse, c); }
        public long[] LONG(int l) { return R(long.Parse, l); }
        public long[][] LONG(int l, char c) { return R(long.Parse, l, c); }
        public double DOUBLE() { return R(double.Parse); }
        public double[] DOUBLE(char c) { return R(double.Parse, c); }
        public double[] DOUBLE(int l) { return R(double.Parse, l); }
        public double[][] DOUBLE(int l, char c) { return R(double.Parse, l, c); }
        public void WRITE(string s, bool lf = true) { W(v => v, s, lf); }
        public void WRITE(int s, bool lf = true) { W(v => v.ToString(), s, lf); }
        public void WRITE(long s, bool lf = true) { W(v => v.ToString(), s, lf); }
        public void WRITE(double s, bool lf = true) { W(v => v.ToString(), s, lf); }
        public void FLUSH() { Console.Write(S); S.Length = 0; }
    }
}

提出情報

提出日時
問題 D - へんてこ辞書
ユーザ nokonoko
言語 C# (Mono 3.2.1.0)
得点 0
コード長 3156 Byte
結果 WA
実行時間 2042 ms
メモリ 38000 KiB

ジャッジ結果

セット名 Sample Subtask1 All
得点 / 配点 0 / 0 0 / 50 0 / 50
結果
AC × 2
AC × 2
WA × 10
AC × 3
WA × 11
TLE × 11
セット名 テストケース
Sample subtask0_sample_01.txt, subtask0_sample_03.txt
Subtask1 subtask0_0.txt, subtask0_1.txt, subtask0_2.txt, subtask0_3.txt, subtask0_4.txt, subtask0_5.txt, subtask0_6.txt, subtask0_7.txt, subtask0_8.txt, subtask0_9.txt, subtask0_sample_01.txt, subtask0_sample_03.txt
All subtask0_0.txt, subtask0_1.txt, subtask0_2.txt, subtask0_3.txt, subtask0_4.txt, subtask0_5.txt, subtask0_6.txt, subtask0_7.txt, subtask0_8.txt, subtask0_9.txt, subtask0_sample_01.txt, subtask0_sample_03.txt, subtask1_0.txt, subtask1_1.txt, subtask1_10.txt, subtask1_11.txt, subtask1_2.txt, subtask1_3.txt, subtask1_4.txt, subtask1_5.txt, subtask1_6.txt, subtask1_7.txt, subtask1_8.txt, subtask1_9.txt, subtask1_sample_02.txt
ケース名 結果 実行時間 メモリ
subtask0_0.txt WA 235 ms 18588 KiB
subtask0_1.txt WA 199 ms 17828 KiB
subtask0_2.txt WA 205 ms 18340 KiB
subtask0_3.txt WA 190 ms 16152 KiB
subtask0_4.txt WA 207 ms 20732 KiB
subtask0_5.txt WA 192 ms 17700 KiB
subtask0_6.txt WA 189 ms 16104 KiB
subtask0_7.txt WA 198 ms 18224 KiB
subtask0_8.txt WA 184 ms 16152 KiB
subtask0_9.txt WA 200 ms 18424 KiB
subtask0_sample_01.txt AC 146 ms 10136 KiB
subtask0_sample_03.txt AC 146 ms 10036 KiB
subtask1_0.txt TLE 2037 ms 37996 KiB
subtask1_1.txt TLE 2039 ms 37888 KiB
subtask1_10.txt TLE 2040 ms 37404 KiB
subtask1_11.txt AC 154 ms 10136 KiB
subtask1_2.txt TLE 2042 ms 37780 KiB
subtask1_3.txt TLE 2037 ms 37752 KiB
subtask1_4.txt TLE 2037 ms 37780 KiB
subtask1_5.txt TLE 2038 ms 37876 KiB
subtask1_6.txt TLE 2041 ms 38000 KiB
subtask1_7.txt TLE 2038 ms 37904 KiB
subtask1_8.txt TLE 2040 ms 37864 KiB
subtask1_9.txt TLE 2040 ms 37984 KiB
subtask1_sample_02.txt WA 148 ms 10104 KiB