# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
34944 | long10024070 | 스파이 (JOI13_spy) | C++11 | 2000 ms | 2416 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#define Link ""
#include <iostream>
#include <cstdio>
#include <vector>
#define TASK "SPY"
using namespace std;
void OpenFile()
{
freopen(".INP","r",stdin);
freopen(".OUT","w",stdout);
}
const int maxn = 2e3 + 1;
int n,m,lab[maxn],res[maxn];
vector <int> e[2][maxn];
int FastIn()
{
int res;
cin >> res;
return res;
// int res = 0;
// register char c = getchar();
// while (c < '0' || '9' < c) c = getchar();
// while ('0' <= c && c <= '9') res = res * 10 + c - '0', c = getchar();
// return res;
}
void Enter()
{
n = FastIn();
m = FastIn();
for (int i=1;i<=n;++i) {
e[0][FastIn()].push_back(i);
e[1][FastIn()].push_back(i);
}
}
void Init()
{
}
void DFS(int t, int u)
{
if (t == 0)
lab[u] = m;
else
if (lab[u] == m)
++res[u];
for (int v : e[t][u])
DFS(t,v);
}
void Solve()
{
for (;m>0;--m) {
int R,S;
cin >> R >> S;
DFS(0,R);
DFS(1,S);
}
for (int i=1;i<=n;++i)
cout << res[i] << '\n';
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
//OpenFile();
Enter();
Init();
Solve();
}
컴파일 시 표준 에러 (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... |