Submission #35017

#TimeUsernameProblemLanguageResultExecution timeMemory
35017nad312스파이 (JOI13_spy)C++14
100 / 100
356 ms10512 KiB
#include<bits/stdc++.h> using namespace std; typedef long long int lli; lli a, b, c, d, e, f, g, h, parx[2009], pary[2009], root, ans[2009]={}, cnt[2009]={}; vector<lli> D[2009], x[2009]; void DSF(lli u) { for(auto v: x[u]) { cnt[v]++; } lli m=u; while(m!=0) { ans[u]+=cnt[m]; m=pary[m]; } for(auto v: D[u]) { DSF(v); } for(auto v: x[u]) { cnt[v]--; } } int main() { //freopen("test.inp","r",stdin); cin>>a>>b; for(int i=1;i<=a;i++) { cin>>parx[i]>>pary[i]; if(parx[i]==0) { root==i; } D[parx[i]].push_back(i); } for(int i=1;i<=b;i++) { cin>>c>>d; x[c].push_back(d); } DSF(root); for(int i=1;i<=a;i++) { cout<<ans[i]<<endl; } }

Compilation message (stderr)

spy.cpp: In function 'int main()':
spy.cpp:36:8: warning: statement has no effect [-Wunused-value]
    root==i;
        ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...