QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#788393#8519. Radarscjr2010WA 0ms3936kbC++141.3kb2024-11-27 16:46:132024-11-27 16:46:13

Judging History

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

  • [2024-11-27 16:46:13]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3936kb
  • [2024-11-27 16:46:13]
  • 提交

answer

/*
考虑优化暴力dp的状态
明确可以用啥判断棋盘全被覆盖
就是找到棋盘被覆盖的一些简单的充要条件
发现只要四个角都被覆盖即可 那就做完了
*/
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define inf 0x3f3f3f3f3f3f3f3fll
#define For(i,l,r) for(int i=(l);i<=(r);++i)
#define Rof(i,l,r) for(int i=(l);i>=(r);--i)
bool M_S;
const int N=505;
int n,a[N][N],f[(1<<4)];
void MAIN1(){
	cin>>n;
	For(i,1,n) For(j,1,n) cin>>a[i][j];
	if(n==1){
		cout<<a[1][1]<<"\n";
		return ;
	}
	memset(f,0x3f,sizeof(f));
	f[0]=0;
	For(i,1,n) For(j,1,n){
		#define dis(x,y) min(abs((x)-i),abs((y)-j))
		For(s,0,(1<<4)-1){
			int t=s;
			if(dis(1,1)<=n/2) t|=(1<<0);
			if(dis(1,n)<=n/2) t|=(1<<1);
			if(dis(n,1)<=n/2) t|=(1<<2);
			if(dis(n,n)<=n/2) t|=(1<<3);
			f[t]=min(f[t],f[s]+a[i][j]);
		}
	}
	cout<<f[(1<<4)-1]<<"\n";
}
void _MAIN1(){}
int T;
void MAIN(){
	cin>>T;
	For(_,1,T) MAIN1(),_MAIN1();
}
bool M_T;
signed main(){
    // freopen(".in","r",stdin);
    // freopen(".out","w",stdout);
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    double T_S=clock();MAIN();double T_T=clock();
    cerr<<"T:"<<(T_T-T_S)/CLOCKS_PER_SEC<<"s ";
    cerr<<"M:"<<(&M_S-&M_T)/1048576<<"MiB\n";
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3936kb

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
1

result:

wrong answer 2nd numbers differ - expected: '5', found: '1'