# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
34980 | 2017-11-17T09:07:14 Z | itsjustwinds | 스파이 (JOI13_spy) | C++11 | 176 ms | 262100 KB |
#include<bits/stdc++.h> #define maxn 2005 using namespace std; int n,r1,r2; bitset<500005> a[maxn],b[maxn]; vector<int > e1[maxn],e2[maxn]; bitset<500005> c; void read(int &a) { a=0; char s=getchar(); for(;s>='0'&&s<='9';s=getchar()) { a=a*10+s-'0'; } } void dfs1(int u) { for (int i=0;i<e1[u].size();++i) { int v=e1[u][i]; a[v]=a[v]|a[u]; dfs1(v); } } void dfs2(int u) { for (int i=0;i<e2[u].size();++i) { int v=e2[u][i]; b[v]=b[v]|b[u]; dfs2(v); } } int p,q,u,v; int main() { //freopen("SPY.inp","r",stdin); int test; read(n); read(test); //cin>>n>>test; for (int i=1;i<=n;++i) { read(p); read(q); if (p) e1[p].push_back(i); else r1=i; if (q) e2[q].push_back(i); else r2=i; } while(test--) { read(u); read(v); a[u].set(test+1); b[v].set(test+1); } dfs1(r1); dfs2(r2); for (int i=1;i<=n;++i) { c=a[i]&b[i]; printf("%d\n",c.count()); } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 33 ms | 259032 KB | Output is correct |
2 | Correct | 16 ms | 259032 KB | Output is correct |
3 | Correct | 16 ms | 246936 KB | Output is correct |
4 | Correct | 33 ms | 246936 KB | Output is correct |
5 | Correct | 23 ms | 247788 KB | Output is correct |
6 | Correct | 26 ms | 247912 KB | Output is correct |
7 | Correct | 19 ms | 252128 KB | Output is correct |
8 | Correct | 23 ms | 248888 KB | Output is correct |
9 | Correct | 0 ms | 246936 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 6 ms | 262100 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 176 ms | 262096 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |