# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
704147 | karrigan | 스파이 (JOI13_spy) | C++14 | 388 ms | 36184 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
int tme=0;
int in[2009];
int out[2009];
int a[2009];
int b[2009];
int num[2009][2009];
int dp[2009][2009];;
int cal(int i,int j){
if (!i||!j)return 0;
if (num[i][j])return dp[i][j];
num[i][j]=1;
return dp[i][j]+=cal(i,b[j])+cal(a[i],j)-cal(a[i],b[j]);
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
int r1=0,r2=0;
int n,m;
cin>>n>>m;
for (int i=1;i<=n;i++){
cin>>a[i]>>b[i];
}
for (int i=1;i<=m;i++){
int x,y;
cin>>x>>y;
dp[x][y]++;
}
for (int i=1;i<=n;i++){
cout<<cal(i,i)<<'\n';
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |