Codeforces 463C Gargari and Bishops(贪心)
来源:互联网 发布:linux安装spark 编辑:程序博客网 时间:2024/05/29 18:44
题目链接:Codeforces 463C Gargari and Bishops
题目大意:在一个n∗n的国际象棋的棋盘上放两个主教,要求不能有位置同时被两个主教攻击到,然后被一个主教攻击到的位置上获得得分。求得分的最大值。
解题思路:黑白格分开考虑最大值,注意全0的时候。
#include <cstdio>#include <cstring>#include <algorithm>using namespace std;#define add(a,b) ((a)+(b))#define del(a,b) ((a)-(b)+2000)const int maxn = 2005;typedef long long ll;int n;ll g[maxn][maxn], l[maxn*2], r[maxn*2];int main () { scanf("%d", &n); memset(l, 0, sizeof(l)); memset(r, 0, sizeof(r)); for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) { scanf("%lld\n", &g[i][j]); l[add(i, j)] += g[i][j]; r[del(i, j)] += g[i][j]; } int odd_x, odd_y, even_x, even_y; ll max_odd = -1, max_even = -1; for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { if ((i+j)&1) { if (max_odd < l[add(i, j)] + r[del(i, j)] - g[i][j]) { max_odd = l[add(i, j)] + r[del(i, j)] - g[i][j]; odd_x = i; odd_y = j; } } else { if (max_even < l[add(i, j)] + r[del(i, j)] - g[i][j]) { max_even = l[add(i, j)] + r[del(i, j)] - g[i][j]; even_x = i; even_y = j; } } } } printf("%lld\n%d %d %d %d\n", max_even + max_odd, odd_x, odd_y, even_x, even_y); return 0;}
0 0
- Codeforces 463C Gargari and Bishops(贪心)
- Codeforces 463C Gargari and Bishops 贪心+规律
- CF 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 463C Gargari and Bishops【模拟】
- 【CODEFORCES】C. Gargari and Bishops
- CodeForce 463C Gargari and Bishops(贪心+暴力)
- 【CodeForces】Gargari and Bishops
- CodeForces】Gargari and Bishops
- Codeforces 436C Gargari and Bishops
- CodeForces463C Gargari and Bishops(贪心)
- Codeforces Round #264 (Div. 2) C Gargari and Bishops 【暴力】
- Codeforces Round 264(div2) C. Gargari and Bishops
- Codeforces #264 (Div. 2) C. Gargari and Bishops
- COdeforces Round #264 (Div. 2) C. Gargari and Bishops
- hdu1237
- Linux系统调用(国嵌)
- 《JavaScript高级程序设计 第三版》学习笔记 (七) 内存泄漏详解
- 暑期英语总结
- hdu 1339
- Codeforces 463C Gargari and Bishops(贪心)
- android SQLite数据库
- 双向链表的创建和相关操作
- 喷水装置(一)
- 八月英语总结
- tab-size, word-wrap属性的应用
- 正则表达式学习正式记录
- Valid Parentheses
- hdu 1408