QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#444492#8519. Radarsucup-team3792#WA 1ms3640kbC++141.1kb2024-06-15 19:35:302024-06-15 19:35:31

Judging History

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

  • [2024-06-15 19:35:31]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3640kb
  • [2024-06-15 19:35:30]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
int t,n,a[505][505],ans;
int v[4][4];
void dfs(int x,int y,int sum,array<int,4> fl)
{
	if(y==4)
	{
		dfs(x+1,1,sum,fl);
		return ;
	}
	if(x==4)
	{
		if(*min_element(fl.begin(),fl.end())==1)
		{
			ans=min(ans,sum);
		}
		return ;
	}
	dfs(x,y+1,sum,fl);
	auto nxt=fl;
	if(x<=2&&y<=2) nxt[0]=1;
	if(x>=2&&y<=2) nxt[1]=1;
	if(x<=2&&y>=2) nxt[2]=1;
	if(x>=2&&y>=2) nxt[3]=1;
	dfs(x,y+1,sum+v[x][y],nxt);
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>t;
	while(t--)
	{
		cin>>n;
		for(int i=1;i<=n;i++)
		{
			for(int j=1;j<=n;j++)
			{
				cin>>a[i][j];
			}
		}
		if(n==1)
		{
			cout<<a[1][1]<<"\n";
			continue ;
		}
		ans=a[n/2+1][n/2+1];
		memset(v,0x3f,sizeof(v));
		for(int i=1;i<=n;i++)
		{
			for(int j=1;j<=n;j++)
			{
				int v1,v2;
				if(i<=n/2) v1=1;
				if(i==n/2+1) v1=2;
				if(i>n/2+1) v1=3;
				if(j<=n/2) v2=1;
				if(j==n/2+1) v2=2;
				if(j>n/2+1) v2=3;
				v[v1][v2]=min(v[v1][v2],a[i][j]); 
			}
		}
		dfs(1,1,0,{0,0,0,0});
		cout<<ans<<"\n";
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 3640kb

input:

1
1
444739567

output:

444739567

result:

ok 1 number(s): "444739567"

Test #3:

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

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:

-2142970301
-2145282102
47298040
226890388
50684672
954430705
139405747
-2143145341
-2145492649
211829225
-2143442557
-2143862759
35580250
-2146569819
230866303
-2145056559
215243437
-2147027945
-2129970503
-2143633390
-2138267675
75128942
-2144241017
755829169
-2133258558
108744675
691515792
-21452...

result:

wrong answer 1st numbers differ - expected: '494991369', found: '-2142970301'