QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#442253#8519. Radarsucup-team3548#WA 1ms1544kbC++171.9kb2024-06-15 10:39:312024-06-15 10:39:32

Judging History

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

  • [2024-06-15 10:39:32]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:1544kb
  • [2024-06-15 10:39:31]
  • 提交

answer

#include<cstdio>
#include<algorithm>
#define ll long long
using namespace std;
int Read()
{
	int Output=0;
	char Input=getchar();
	while(Input<'0'||Input>'9')
	Input=getchar();
	while(Input>='0'&&Input<='9')
	{
		Output=Output*10+Input-'0';
		Input=getchar();
	}
	return Output;
}
int T;
int N;
int A[501][501];
int Vis[501][501];
struct point
{
	int X,Y;
}Four[11];
ll Answer;
point Search(int Xa,int Ya,int Xb,int Yb)
{
	point Ans=(point){Xa,Ya};
	for(int i=Xa;i<=Xb;++i)
	{
		for(int j=Ya;j<=Yb;++j)
		{
			if(A[i][j]<A[Ans.X][Ans.Y])
			Ans=(point){i,j};
		}
	}
	return Ans;
}
bool Check()
{
	for(int i=1;i<=N;++i)
	for(int j=1;j<=N;++j)
	if(!Vis[i][j])
	return false;
	return true;
}
void DFS(int Deep,ll Val)
{
	if(Deep==10)
	{
		if(Check())
		Answer=min(Answer,Val);
		return;
	}
	for(int i=max(Four[Deep].X-(N>>1),1);i<=min(Four[Deep].X+(N>>1),N);++i)
	for(int j=max(Four[Deep].Y-(N>>1),1);j<=min(Four[Deep].Y+(N>>1),N);++j)
	++Vis[i][j];
	DFS(Deep+1,Val+A[Four[Deep].X][Four[Deep].Y]);
	for(int i=max(Four[Deep].X-(N>>1),1);i<=min(Four[Deep].X+(N>>1),N);++i)
	for(int j=max(Four[Deep].Y-(N>>1),1);j<=min(Four[Deep].Y+(N>>1),N);++j)
	--Vis[i][j];
	DFS(Deep+1,Val);
}
int main()
{
	T=Read();
	while(T--)
	{
		Answer=1e15;
		N=Read();
		if(N==1)
		{
			printf("%d\n",Read());
			continue;
		}
		for(int i=1;i<=N;++i)
		{
			for(int j=1;j<=N;++j)
			{
				A[i][j]=Read();
			}
		}
		Four[1]=Search(1,1,(N>>1)+1,(N>>1)+1);
		Four[2]=Search(1,(N>>1)+1,(N>>1)+1,N);
		Four[3]=Search((N>>1)+1,1,N,(N>>1)+1);
		Four[4]=Search((N>>1)+1,(N>>1)+1,N,N);
		Four[5]=(point){(N>>1)+1,(N>>1)+1};
		Four[6]=Search((N>>1)+1,1,(N>>1)+1,(N>>1)+1);
		Four[7]=Search((N>>1)+1,(N>>1)+1,(N>>1)+1,N);
		Four[8]=Search(1,(N>>1)+1,(N>>1)+1,(N>>1)+1);
		Four[9]=Search((N>>1)+1,(N>>1)+1,(N>>1)+1,N);
		DFS(1,0);
		printf("%lld\n",Answer);
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 1544kb

input:

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

output:

1
5

result:

ok 2 number(s): "1 5"

Test #2:

score: 0
Accepted
time: 0ms
memory: 1504kb

input:

1
1
444739567

output:

444739567

result:

ok 1 number(s): "444739567"

Test #3:

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

input:

32
5
177252602 814271963 432801178 401470194 888319541
320323627 34071000 116035631 87392694 926990496
423510770 515133425 777623990 140441392 853473387
976288681 925949889 930584554 939702106 761328886
840677679 912446055 378955738 997133668 334407172
3
633852912 89450314 828384045
327867173 732812...

output:

494991369
732812691
47298040
226890388
50684672
954430705
139405747
530064327
199272913
211829225
333898451
217089022
35580250
251879512
230866303
60323753
215243437
114032585
351186098
361741480
49710371
75128942
269414925
755829169
133537759
108744675
691515792
193230413
469380143
156043031
227141...

result:

wrong answer 2nd numbers differ - expected: '661643843', found: '732812691'