codeforces 463C Gargari and Bishops
2024-10-10 07:54:39
这个题, 最主要的应该是找到对角线上的格子的关系。 “ \" 这种对角线, 关系是x-y+n相等, ” / “ 这种, 关系是x+y相等。知道每个格子的两种对角线的值, 那么这个格子的值可以表示为d1[x+y]+d2[x-y+n]-a[x][y], a[x][y]是初值。 知道这个以后就好做了。
具体可以看这里http://blog.csdn.net/kenden23/article/details/38959141.....
#include<bits/stdc++.h>
using namespace std;
#define pb(x) push_back(x)
#define ll long long
#define mk(x, y) make_pair(x, y)
#define lson l, m, rt<<1
#define mem(a) memset(a, 0, sizeof(a))
#define rson m+1, r, rt<<1|1
#define mem1(a) memset(a, -1, sizeof(a))
#define mem2(a) memset(a, 0x3f, sizeof(a))
#define rep(i, a, n) for(int i = a; i<n; i++)
#define ull unsigned long long
typedef pair<int, int> pll;
const double PI = acos(-1.0);
const double eps = 1e-;
const int mod = 1e9+;
const int inf = ;
const int dir[][] = { {-, }, {, }, {, -}, {, } };
ll a[][], d1[], d2[];
int ans[][];
int main()
{
int n;
cin>>n;
for(int i = ; i<n; i++) {
for(int j = ; j<n; j++) {
scanf("%d", &a[i][j]);
d1[i+j] += a[i][j];
d2[i-j+n] += a[i][j];
}
}
for(int i = ; i<n; i++) {
for(int j = ; j<n; j++) {
a[i][j] = d1[i+j]+d2[i-j+n]-a[i][j];
}
}
ans[][] = ans[][] = ans[][] = ;
ans[][] = ;
for(int i = ; i<n; i++) {
for(int j = ; j<n; j++) {
if((i+j)&) {
if(a[i][j]>a[ans[][]][ans[][]]) {
ans[][] = i;
ans[][] = j;
}
} else {
if(a[i][j]>a[ans[][]][ans[][]]) {
ans[][] = i;
ans[][] = j;
}
}
}
}
cout<<a[ans[][]][ans[][]]+a[ans[][]][ans[][]]<<endl;
cout<<ans[][]+<<" "<<ans[][]+<<" "<<ans[][]+<<" "<<ans[][]+<<endl;
}
最新文章
- php7.0支持调用lua脚本
- Mysql学习笔记(三)运算符和控制流函数
- JavaEE基础(十四) /正则
- Python LOGGING使用方法
- HDU-3864 D_num Miller_Rabin和Pollard_rho
- HW6.22
- shell脚本采用crontab定时备份数据库日志
- MySQL查询统计,统计唯一值并分组
- 自定义滚动条 niceScroll 配置参数
- 《深入了解 Linq to SQL》之对象的标识 —— 麦叔叔呕心呖血之作
- MVC不错的学习资料
- Java开源内容管理CMS系统J4CMS的几个样式
- java面向对象--抽象类和接口
- fiddler mock ==>; AutoResponder
- 【iOS】swift 排序Sort函数用法(包含NSDictionary排序)
- svn仓库迁移
- linux内核中的linuxPPS是什么?
- centos-yum离线源
- 页面用一个遮罩层显示加载,加载完后隐藏该div
- Egret容器的鼠标默认事件