結果

問題 No.482 あなたの名は
ユーザー 14番
提出日時 2017-02-12 00:22:33
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 1,601 bytes
コンパイル時間 1,411 ms
コンパイル使用メモリ 112,784 KB
実行使用メモリ 48,388 KB
最終ジャッジ日時 2024-12-29 16:44:33
合計ジャッジ時間 4,841 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17 WA * 11
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Text;
 
public class Program
{
    public void Proc() {
        Reader.IsDebug = false;
        bool ans = this.GetAns();
        Console.WriteLine(ans?"YES":"NO");
    }

    private bool GetAns() {
        long[] inpt = Reader.ReadLine().Split(' ').Select(a=>long.Parse(a)).ToArray();
        int itemCount = (int)inpt[0];
        long nokori = inpt[1];

        int[] items = Reader.ReadLine().Split(' ').Select(a=>int.Parse(a)).ToArray();
        for(int i=1; i<=itemCount; i++) {
            if(items[i-1] != i) {
                if(nokori <= 0) {
                    return false;
                }
                int num = items[i-1];
                int num2 = items[num-1];
                items[i-1] = num2;
                items[num-1] = num;
                nokori--;
            }
        }
        return nokori % 2 == 0;
    }




    public class Reader {
        public static bool IsDebug = true;
        private static System.IO.StringReader SReader;
        private static string InitText = @"


4 2
1 2 3 4

";
        public static string ReadLine() {
            if(IsDebug) {
                if(SReader == null) {
                    SReader = new System.IO.StringReader(InitText.Trim());
                }
                return SReader.ReadLine();
            } else {
                return Console.ReadLine();
            }
        }
    }
    public static void Main(string[] args)
    {
        Program prg = new Program();
        prg.Proc();
    }
}
0