結果
問題 | No.482 あなたの名は |
ユーザー |
|
提出日時 | 2017-02-10 22:40:31 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 148 ms / 2,000 ms |
コード長 | 776 bytes |
コンパイル時間 | 256 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 29,608 KB |
最終ジャッジ日時 | 2024-12-29 19:17:06 |
合計ジャッジ時間 | 4,221 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 28 |
ソースコード
import sysdef debug(x, table):for name, val in table.items():if x is val:print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)return Nonedef solve():N, K = map(int, input().split())Ds = [int(i) - 1 for i in input().split()]checked = [False] * Nnum_gokan = 0for i in range(N):if checked[i]:continuechecked[i] = Truelen_cyc = 0nxt = Ds[i]while not checked[nxt]:checked[nxt] = Truenxt = Ds[nxt]len_cyc += 1num_gokan += len_cycif num_gokan <= K and num_gokan % 2 == K % 2:ans = 'YES'else:ans = 'NO'print(ans)if __name__ == '__main__':solve()