QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#41192#4376. Dragon slayeryoungsystem#WA 241ms3608kbC++2.3kb2022-07-28 17:01:062022-07-28 17:01:07

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-07-28 17:01:07]
  • 评测
  • 测评结果:WA
  • 用时:241ms
  • 内存:3608kb
  • [2022-07-28 17:01:06]
  • 提交

answer

#include<iostream>
#include<cstdio>
#include<vector>
#include<bitset> 
#define mod 1000000007
using namespace std;
inline int read()
{
	int n=0,f=1,ch=getchar();
	while(ch<'0'||ch>'9')
	{
		if(ch=='-')f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9')
	{
		n=n*10+ch-'0';
		ch=getchar();
	}
	return n*f;
} 
int tsl[20][20][4],nsl[20][20][4];
bool vis[20][20];
int n,m;
void dfs(int x,int y)
{
	if(x<0||x>n||y<0||y>m)return;
	if(vis[x][y])return;
	vis[x][y]=true;
	if(x>=1&&nsl[x][y][3]==0)dfs(x-1,y);
	if(x<=n-1&&nsl[x][y][1]==0)dfs(x+1,y);
	if(y>=1&&nsl[x][y][2]==0)dfs(x,y-1);
	if(y<=m-1&&nsl[x][y][0]==0)dfs(x,y+1);
}
int lx[20],ly[20],yx[20],yy[20];
int main()
{
	int t,k,xs,ys,xt,yt,ans;
	int x0,y0,x1,y1;
	t=read();
	for(int greg=1;greg<=t;greg++)
	{
		n=read();
		m=read();
		k=read();
		xs=read();
		ys=read();
		xt=read();
		yt=read();
		ans=k;
		for(int i=0;i<=n;i++)
		{
			for(int j=0;j<=m;j++)
			{
				tsl[i][j][0]=tsl[i][j][1]=tsl[i][j][2]=tsl[i][j][3]=0;
			}
		}
		for(int i=1;i<=k;i++)
		{
			x0=read();
			y0=read();
			x1=read();
			y1=read();
			lx[i]=x0;
			ly[i]=y0;
			yx[i]=x1;
			yy[i]=y1; 
			if(x0==x1)
			{
				if(y0>y1)swap(y0,y1);
				for(int i=y0;i<=y1-1;i++)
				{
					if(x0!=0)tsl[x0-1][i][1]++;
					tsl[x0][i][3]++;
				}
			}
			else
			{
				if(x0>x1)swap(x0,x1);
				for(int i=x0;i<=x1-1;i++)
				{
					if(y0!=0)tsl[i][y0-1][0]++;
					tsl[i][y0][2]++;
				}
			}
		}
		for(int now=1;now<(1<<k);now++)
		{
			for(int i=0;i<=n;i++)
			{
				for(int j=0;j<=m;j++)
				{
					nsl[i][j][0]=tsl[i][j][0];
					nsl[i][j][1]=tsl[i][j][1];
					nsl[i][j][2]=tsl[i][j][2];
					nsl[i][j][3]=tsl[i][j][3];
					vis[i][j]=false;
				}
			}
			for(int j=1;j<=k;j++)
			{
				if((now&(1<<(j-1)))!=0)continue;
				x0=lx[j];
				y0=ly[j];
				x1=yx[j];
				y1=yy[j];
				if(x0==x1)
				{
					if(y0>y1)swap(y0,y1);
					for(int i=y0;i<=y1-1;i++)
					{
						if(x0!=0)tsl[x0-1][i][1]++;
						tsl[x0][i][3]++;
					}
				}
				else
				{
					if(x0>x1)swap(x0,x1);
					for(int i=x0;i<=x1-1;i++)
					{
						if(y0!=0)tsl[i][y0-1][0]++;
						tsl[i][y0][2]++;
					}
				}
			}
			dfs(xs,ys);
			if(vis[xt][yt]==true)ans=min(ans,k-__builtin_popcount(now));
		}
		printf("%d\n",ans);
	}
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 241ms
memory: 3608kb

input:

10
4 4 4 0 2 3 3
0 2 4 2
1 3 1 0
2 4 2 1
3 1 3 4
3 2 2 0 0 2 1
0 1 3 1
1 0 1 2
3 2 2 0 0 2 1
2 1 2 2
1 0 1 1
15 15 15 3 12 4 1
8 0 8 15
1 11 15 11
1 1 1 15
3 1 3 15
0 10 14 10
14 1 14 14
8 1 8 15
1 5 14 5
0 15 14 15
0 4 14 4
0 2 15 2
11 0 11 15
4 1 4 15
1 11 15 11
1 12 14 12
15 15 15 8 5 14 0
0 12 1...

output:

0
2
0
15
15
15
15
15
15
0

result:

wrong answer 1st lines differ - expected: '1', found: '0'