QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#512991#9170. Cycle Gameucup-team1004#WA 1ms7808kbC++141.0kb2024-08-10 16:33:252024-08-10 16:33:26

Judging History

你现在查看的是最新测评结果

  • [2024-08-10 16:33:26]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:7808kb
  • [2024-08-10 16:33:25]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N=1e6+10,fx[4]={1,0,-1,0},fy[4]={0,1,0,-1};
int n,m,k,fa[N],V=0,E=0,C=0,F=1,ans[N],p[N];
int id(int x,int y){return (x-1)*m+y;}
int getfa(int x){return x==fa[x]?x:(fa[x]=getfa(fa[x]));}
bool chk(int x,int y)
{
	for(int i=-1;i<=0;i++)
		for(int j=-1;j<=0;j++)
			if(!p[id(x+i,y+j)]) return 0;
	return 1;
}
int main()
{
	scanf("%d%d%d",&n,&m,&k);
	n+=2,m+=2;
	for(int i=1,x,y;i<=k;i++)
	{
		scanf("%d%d",&x,&y),x++,y++;
		vector<int> v{id(x,y)};
		for(int j=0;j<4;j++)
		{
			int X=x+fx[j],Y=y+fy[j];
			if(p[id(X,Y)]) v.push_back(getfa(id(X,Y)));
		}
		int e=v.size()-1,f=0;
		p[id(x,y)]=1;
		sort(v.begin(),v.end());
		v.erase(unique(v.begin(),v.end()),v.end());
		int c=2-(int)v.size();
		for(int i=0;i<2;i++)
			for(int j=0;j<2;j++)
				f+=chk(x+i,y+j);
		if(c==1-e+f)
		{
			C+=c,V++,F+=f,E+=e;
			ans[i]=1;
			for(int i=1;i<(int)v.size();i++)
				fa[getfa(v[i])]=getfa(v[0]);
		}
		else p[id(x,y)]=0;
	}
	for(int i=1;i<=k;i++) putchar(ans[i]+'0');
	puts("");
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 7760kb

input:

4 3 7
2 1
2 2
2 3
3 1
3 2
4 1
4 2

output:

1111111

result:

ok "1111111"

Test #2:

score: 0
Accepted
time: 1ms
memory: 7764kb

input:

3 3 8
1 1
1 2
1 3
2 3
3 3
3 2
3 1
2 1

output:

11111110

result:

ok "11111110"

Test #3:

score: 0
Accepted
time: 1ms
memory: 7740kb

input:

10 10 7
9 1
6 6
3 8
8 7
5 10
1 7
1 2

output:

1111111

result:

ok "1111111"

Test #4:

score: -100
Wrong Answer
time: 1ms
memory: 7808kb

input:

9 10 50
1 9
1 6
2 3
3 1
7 4
9 4
1 3
2 5
9 2
7 9
5 6
8 10
9 5
5 5
4 10
9 7
5 9
3 2
4 5
1 1
4 7
3 6
2 8
4 3
8 6
5 10
4 8
5 4
7 2
9 6
4 2
7 8
5 2
3 5
9 1
6 1
1 5
9 9
5 8
6 3
8 8
8 4
7 7
7 1
3 7
2 2
3 10
6 9
8 3
7 6

output:

11111111111111111111111110111001101101011010001010

result:

wrong answer 1st words differ - expected: '11111111111111111111111111111111111111111111111111', found: '11111111111111111111111110111001101101011010001010'