結果
問題 |
No.3217 Shiki no Shiki
|
ユーザー |
![]() |
提出日時 | 2025-08-01 21:30:36 |
言語 | D (dmd 2.109.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 395 bytes |
コンパイル時間 | 2,207 ms |
コンパイル使用メモリ | 87,076 KB |
実行使用メモリ | 7,716 KB |
最終ジャッジ日時 | 2025-08-01 21:30:40 |
合計ジャッジ時間 | 1,733 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 4 WA * 19 |
ソースコード
import std.stdio, std.algorithm, std.array, std.conv, std.typecons; alias Set = bool[3 * 10^^5]; void main() { readln; auto P = readln.split.to!(ulong[]); P = [0UL] ~ P; auto N = P.length-1; auto isnot_top = new bool[N+1]; foreach (p; P) { isnot_top[p] = true; } ulong ans; foreach (i; 1 .. N+1) if (!isnot_top[i]){ if (P[i] != 0 && P[P[i]] != 0) ans++; } writeln(ans); }