Submission #215053


Source Code Expand

Copy
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;
using System.IO;
using System.Diagnostics;
using Enu = System.Linq.Enumerable;

class Program
{
    void Solve()
    {
        int N = reader.Int(), M = reader.Int(), T = reader.Int();
        int[] next = Enu.Range(0, N).ToArray();
        
        foreach (int R in reader.IntLine().Reverse())
            Swap(ref next[R - 1], ref next[R]);

        int[] res = new int[N];
        bool[] seen = new bool[N];
        for (int i = 0; i < N; i++)
        {
            if (seen[i]) continue;
            var list = new List<int>();
            int p = i;
            while (!seen[p])
            {
                seen[p] = true;
                list.Add(p);
                p = next[p];
            }
            for (int li = 0; li < list.Count; li++)
                res[list[li]] = list[(li + T) % list.Count];
        }

        Console.WriteLine(string.Join("\n", res.Select(x => x + 1)));
    }

    void Swap<T>(ref T a, ref T b) { T t = a; a = b; b = t; }



    static void Main() { new Program().Solve(); }
    Reader reader = new Reader(Console.In);
    class Reader
    {
        private readonly TextReader reader;
        private readonly char[] separator = new char[] { ' ' };
        private readonly StringSplitOptions removeOp = StringSplitOptions.RemoveEmptyEntries;
        private string[] A = new string[0];
        private int i;

        public Reader(TextReader r) { reader = r; }
        public bool HasNext() { return Enqueue(); }
        public string String() { return Dequeue(); }
        public int Int() { return int.Parse(Dequeue()); }
        public long Long() { return long.Parse(Dequeue()); }
        public double Double() { return double.Parse(Dequeue()); }
        public int[] IntLine() { var s = Line(); return s == "" ? new int[0] : Array.ConvertAll(Split(s), int.Parse); }
        public int[] IntArray(int N) { return Enumerable.Range(0, N).Select(i => Int()).ToArray(); }
        public int[][] IntGrid(int H) { return Enumerable.Range(0, H).Select(i => IntLine()).ToArray(); }
        public string[] StringArray(int N) { return Enumerable.Range(0, N).Select(i => Line()).ToArray(); }
        public string Line() { return reader.ReadLine().Trim(); }
        private string[] Split(string s) { return s.Split(separator, removeOp); }
        private bool Enqueue()
        {
            if (i < A.Length) return true;
            string line = reader.ReadLine();
            if (line == null) return false;
            if (line == "") return Enqueue();
            A = Split(line);
            i = 0;
            return true;
        }
        private string Dequeue() { Enqueue(); return A[i++]; }
    }
}

Submission Info

Submission Time
Task D - 阿弥陀
User eitaho
Language C# (Mono 2.10.8.1)
Score 100
Code Size 2855 Byte
Status AC
Exec Time 325 ms
Memory 31296 KB

Judge Result

Set Name Subtask1 Subtask2 Subtask3 Subtask4
Score / Max Score 10 / 10 20 / 20 20 / 20 50 / 50
Status
AC × 9
AC × 18
AC × 18
AC × 29
Set Name Test Cases
Subtask1 sample_1.txt, 01_i.txt, 01_random01.txt, 01_random02.txt, 01_random03.txt, 01_random04.txt, 01_random05.txt, 01_random06.txt, 01_random07.txt
Subtask2 sample_1.txt, sample_2.txt, sample_3.txt, 02_i.txt, 02_p.txt, 02_random01.txt, 02_random02.txt, 02_random03.txt, 02_random04.txt, 02_random05.txt, 02_random06.txt, 02_random07.txt, 02_random08.txt, 02_rp01.txt, 02_rp02.txt, 02_rp03.txt, 02_rp04.txt, 02_rp05.txt
Subtask3 sample_1.txt, sample_2.txt, 03_i.txt, 03_random01.txt, 03_random02.txt, 03_random03.txt, 03_random04.txt, 03_random05.txt, 03_random06.txt, 03_random07.txt, 03_random08.txt, 03_random09.txt, 03_random10.txt, 03_random11.txt, 03_random12.txt, 03_random13.txt, 03_random14.txt, 03_random15.txt
Subtask4 sample_1.txt, sample_2.txt, sample_3.txt, 04_i.txt, 04_p1.txt, 04_p2.txt, 04_random01.txt, 04_random02.txt, 04_random03.txt, 04_random04.txt, 04_random05.txt, 04_random06.txt, 04_random07.txt, 04_random08.txt, 04_random09.txt, 04_random10.txt, 04_random11.txt, 04_random12.txt, 04_random13.txt, 04_rp01.txt, 04_rp02.txt, 04_rp03.txt, 04_rp04.txt, 04_rp05.txt, 04_rp06.txt, 04_rp07.txt, 04_rp08.txt, 04_rp09.txt, 04_rp10.txt
Case Name Status Exec Time Memory
01_i.txt AC 312 ms 30280 KB
01_random01.txt AC 168 ms 7620 KB
01_random02.txt AC 146 ms 7700 KB
01_random03.txt AC 150 ms 7740 KB
01_random04.txt AC 154 ms 8520 KB
01_random05.txt AC 223 ms 16036 KB
01_random06.txt AC 276 ms 20172 KB
01_random07.txt AC 311 ms 28736 KB
02_i.txt AC 154 ms 7824 KB
02_p.txt AC 154 ms 7956 KB
02_random01.txt AC 153 ms 7756 KB
02_random02.txt AC 148 ms 7684 KB
02_random03.txt AC 153 ms 8000 KB
02_random04.txt AC 151 ms 7828 KB
02_random05.txt AC 159 ms 9036 KB
02_random06.txt AC 194 ms 13588 KB
02_random07.txt AC 229 ms 19316 KB
02_random08.txt AC 227 ms 19404 KB
02_rp01.txt AC 151 ms 7820 KB
02_rp02.txt AC 153 ms 7784 KB
02_rp03.txt AC 170 ms 7884 KB
02_rp04.txt AC 149 ms 7824 KB
02_rp05.txt AC 155 ms 7816 KB
03_i.txt AC 148 ms 7628 KB
03_random01.txt AC 165 ms 8660 KB
03_random02.txt AC 201 ms 17868 KB
03_random03.txt AC 191 ms 16328 KB
03_random04.txt AC 196 ms 16276 KB
03_random05.txt AC 161 ms 9288 KB
03_random06.txt AC 156 ms 9104 KB
03_random07.txt AC 162 ms 10044 KB
03_random08.txt AC 147 ms 7832 KB
03_random09.txt AC 169 ms 10684 KB
03_random10.txt AC 178 ms 13128 KB
03_random11.txt AC 203 ms 17480 KB
03_random12.txt AC 201 ms 17740 KB
03_random13.txt AC 188 ms 15820 KB
03_random14.txt AC 183 ms 13772 KB
03_random15.txt AC 160 ms 10048 KB
04_i.txt AC 313 ms 30152 KB
04_p1.txt AC 250 ms 19992 KB
04_p2.txt AC 230 ms 15688 KB
04_random01.txt AC 238 ms 19748 KB
04_random02.txt AC 200 ms 13900 KB
04_random03.txt AC 203 ms 15436 KB
04_random04.txt AC 244 ms 21184 KB
04_random05.txt AC 238 ms 19844 KB
04_random06.txt AC 232 ms 14020 KB
04_random07.txt AC 273 ms 24904 KB
04_random08.txt AC 254 ms 21784 KB
04_random09.txt AC 264 ms 24132 KB
04_random10.txt AC 212 ms 14224 KB
04_random11.txt AC 314 ms 30984 KB
04_random12.txt AC 313 ms 31296 KB
04_random13.txt AC 307 ms 28488 KB
04_rp01.txt AC 242 ms 20044 KB
04_rp02.txt AC 251 ms 20044 KB
04_rp03.txt AC 253 ms 20044 KB
04_rp04.txt AC 252 ms 20116 KB
04_rp05.txt AC 256 ms 20028 KB
04_rp06.txt AC 261 ms 19968 KB
04_rp07.txt AC 325 ms 20092 KB
04_rp08.txt AC 271 ms 20080 KB
04_rp09.txt AC 250 ms 20048 KB
04_rp10.txt AC 245 ms 20032 KB
sample_1.txt AC 146 ms 7624 KB
sample_2.txt AC 149 ms 7628 KB
sample_3.txt AC 145 ms 7704 KB