Codeforces Round #264 (Div. 2) C. Gargari and Bishops 主教攻击
来源:互联网 发布:陪你读书javascript 编辑:程序博客网 时间:2024/06/05 08:38
http://codeforces.com/contest/463/problem/C
在一个n∗n的国际象棋的棋盘上放两个主教,要求不能有位置同时被两个主教攻击到,然后被一个主教攻击到的位置上获得得分。求得分的最大值。
黑白格分开考虑最大值即可,注意全0情况。
#include <cstdio>#include <cstdlib>#include <cmath>#include <cstring>#include <string>#include <queue>#include <vector>#include<set>#include <iostream>#include <algorithm>using namespace std;#define RD(x) scanf("%d",&x)#define RD2(x,y) scanf("%d%d",&x,&y)#define clr0(x) memset(x,0,sizeof(x))typedef long long LL;int n;const int maxn = 2500;LL s[maxn][maxn];LL sum[maxn*2],cha[maxn*2];struct node{ LL fen; int x,y;}a[maxn*maxn/2],b[maxn*maxn/2];int main(){ RD(n); clr0(sum),clr0(cha); for(int i = 1;i <= n;++i) for(int j = 1;j <= n;++j){ scanf("%I64d",&s[i][j]); sum[i+j] += s[i][j]; cha[j-i+maxn] += s[i][j]; } int cnt_a = 0,cnt_b = 0; for(int i = 1;i <= n;++i) for(int j = 1;j <= n;++j){ LL fen = sum[i+j] + cha[j-i+maxn] - s[i][j]; if((i+j)&1){ a[cnt_a++] = (node){fen,i,j}; } else{ b[cnt_b++] = (node){fen,i,j}; } } LL ans_a = -1,ans_b = -1; int x1,y1,x2,y2; for(int i = 0;i < cnt_a;++i){ if(ans_a < a[i].fen){ ans_a = a[i].fen; x1 = a[i].x,y1 = a[i].y; } } for(int i = 0;i < cnt_b;++i){ if(ans_b < b[i].fen){ ans_b = b[i].fen; x2 = b[i].x,y2 = b[i].y; } } printf("%I64d\n",ans_a+ans_b); printf("%d %d %d %d\n",x1,y1,x2,y2); return 0;}
0 0
- Codeforces Round #264 (Div. 2) C. Gargari and Bishops 主教攻击
- Codeforces Round #264 (Div. 2) C Gargari and Bishops 【暴力】
- COdeforces Round #264 (Div. 2) C. Gargari and Bishops
- Codeforces Round #264 (Div. 2) C. Gargari and Bishops
- Codeforces Round #264 (Div. 2)-C. Gargari and Bishops
- Codeforces Round #264 (Div. 2) C - Gargari and Bishops
- Codeforces #264 (Div. 2) C. Gargari and Bishops
- Codeforces Round 264(div2) C. Gargari and Bishops
- 【CODEFORCES】C. Gargari and Bishops
- 【CodeForces】Gargari and Bishops
- CodeForces】Gargari and Bishops
- Codeforces 463C Gargari and Bishops(贪心)
- Codeforces 463C Gargari and Bishops 题解
- Codeforces 463C. Gargari and Bishops
- Codeforces 463C Gargari and Bishops
- CodeForces 463C - Gargari and Bishops
- Codeforces 436C Gargari and Bishops
- Codeforces 463C Gargari and Bishops【模拟】
- android资料下载
- crontab详解
- Core Animation学习笔记(一)
- java自带线程池和队列详细讲解
- 重写equals方法
- Codeforces Round #264 (Div. 2) C. Gargari and Bishops 主教攻击
- hdu 1002 A + B Problem II
- php获取文件扩展名的方法
- PAT(A) 1029
- Linux crontab 命令格式与详细例子
- java线程中yield(),sleep(),wait()区别详解
- EditPlus使用技巧集
- 为什么不能是 char *p = "test"; ?
- 第9周 项目1-3 运用do-while语句做循环程序求和