結果
| 問題 | No.482 あなたの名は |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-03-21 10:56:10 |
| 言語 | Java (openjdk 23) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 918 bytes |
| 記録 | |
| コンパイル時間 | 3,657 ms |
| コンパイル使用メモリ | 78,744 KB |
| 実行使用メモリ | 71,844 KB |
| 最終ジャッジ日時 | 2024-07-05 05:28:29 |
| 合計ジャッジ時間 | 10,140 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 12 TLE * 1 -- * 15 |
ソースコード
import java.util.ArrayList;
import java.util.Scanner;
public class YourName {
static ArrayList<Integer> list = new ArrayList<>();
static StringBuilder cut = new StringBuilder();
static long K;
static int N;
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
N = s.nextInt();
K = s.nextLong();
list.add(0);
cut.append('0');
for(int i = 1;i<=N;i++){
list.add(s.nextInt());
cut.append('1');
}
s.close();
for(int i = 1;i<=N;){
swtch(i);
if(cut.indexOf("1") == -1){
break;
}else{
i = cut.indexOf("1");
}
}
if(K > 0&&K%2 == 0){
K = 0;
}
if(K == 0)
System.out.println("YES");
else
System.out.println("NO");
}
static void swtch(int i){
if(i != list.get(i)){
int t = list.indexOf(i);
list.set(t, list.get(i));
list.set(i, i);
cut.setCharAt(i, '0');
swtch(t);
K--;
}else{
cut.setCharAt(i, '0');
}
}
}