# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
102117 | jwvg0425 | 스파이 (JOI13_spy) | C++17 | 2069 ms | 219908 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <stdio.h>
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <bitset>
#include <map>
#include <set>
#include <tuple>
#include <string.h>
#include <math.h>
#include <random>
#include <functional>
#include <assert.h>
#include <math.h>
#include <iterator>
#include <chrono>
#define all(x) (x).begin(), (x).end()
#define xx first
#define yy second
using namespace std;
using i64 = long long int;
using ii = pair<int, int>;
using ii64 = pair<i64, i64>;
using vi = vector<long long int>;
int iparent[2005];
int jparent[2005];
vector<int> ichild[2005];
vector<int> jchild[2005];
vector<int> iteams[2005];
vector<int> jteams[2005];
int iroot;
int jroot;
void idfs(int root, int team)
{
iteams[root].push_back(team);
for (auto& c : ichild[root])
idfs(c, team);
}
void jdfs(int root, int team)
{
jteams[root].push_back(team);
for (auto& c : jchild[root])
jdfs(c, team);
}
int main()
{
int n, m;
scanf("%d %d", &n, &m);
for (int i = 1; i <= n; i++)
{
int p, q;
scanf("%d %d", &p, &q);
jparent[i] = p;
jchild[p].push_back(i);
iparent[i] = q;
ichild[q].push_back(i);
if (jparent[i] == 0)
jroot = i;
if (iparent[i] == 0)
iroot = i;
}
for (int i = 1; i <= m; i++)
{
int r, s;
scanf("%d %d", &r, &s);
jdfs(r, i);
idfs(s, i);
}
for (int i = 1; i <= n; i++)
{
sort(all(jteams[i]));
int c = 0;
for (auto& it : iteams[i])
{
if (binary_search(all(jteams[i]), it))
c++;
}
printf("%d\n", c);
}
return 0;
}
컴파일 시 표준 에러 (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... |