답안 #34955

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
34955 2017-11-17T08:51:48 Z nad312 스파이 (JOI13_spy) C++14
0 / 100
0 ms 1840 KB
#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], x[2009][10009]={}, chia=60, y[2009][10009], z[10009], u[10009];
vector<lli> Dx[2009], Dy[2009];
lli next()
{
	register char ch=getchar();
	lli l=0;
	while(ch<'0'||ch>'9')
	{
		ch=getchar();
	}
	while(ch>='0'&&ch<='9')
	{
		l=l*10+ch-'0';
		ch=getchar();
	}
	return l;
}
void DSFx(lli u, lli k)
{
	x[u][k/chia]=x[u][k/chia]|(1<<(k%chia));
	for(auto v: Dx[u])
	{
		DSFx(v, k);
	}
}
void DSFy(lli u, lli k)
{
	y[u][k/chia]=y[u][k/chia]|(1<<(k%chia));
	for(auto v: Dy[u])
	{
		DSFy(v, k);
	}
}
void Inp()
{
	a=next();
	b=next();
	for(int i=1;i<=a;i++)
	{
		parx[i]=next();
		pary[i]=next();
		Dx[parx[i]].push_back(i);
		Dy[pary[i]].push_back(i);
	}
	for(int i=1;i<=b;i++)
	{
		c=next();
		d=next();
		DSFx(c, i);
		DSFy(d, i);
	}
}
void Solve()
{
	h=b/chia;
	for(int i=1;i<=a;i++)
	{
		d=0;
		for(int j=0;j<=h;j++)
		{
			c=(x[i][j]&y[i][j]);
			d=d+__builtin_popcount(c);
		}
		cout<<d<<endl;
	}
}
int main()
{
	//freopen("test.inp","r",stdin);
	Inp();
	Solve();
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 1840 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 1840 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 1840 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -