結果

問題 No.3217 Shiki no Shiki
ユーザー dvasgdjhas
提出日時 2025-08-01 22:36:31
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 546 bytes
コンパイル時間 3,065 ms
コンパイル使用メモリ 283,264 KB
実行使用メモリ 7,716 KB
最終ジャッジ日時 2025-08-01 22:36:35
合計ジャッジ時間 4,407 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 4 WA * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"

signed main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n;cin>>n;
    vector<int> p(n+1),idg(n+1,0);
    for(int i=1;i<=n;i++){
        cin>>p[i];
        if(p[i] != 0)idg[p[i]]++;
    }
    unordered_set<int> s;
    for(int i=1;i<=n;i++){
        if(idg[i]!=0)continue;
        int x = p[i];
        if(x==0)continue;
        int y = p[x];
        if(y==0)continue;
        s.insert(i);
    }
    cout<<s.size();
    return 0;
}
0