题目链接

这个题, 最主要的应该是找到对角线上的格子的关系。 “ \" 这种对角线, 关系是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;
}

最新文章

  1. php7.0支持调用lua脚本
  2. Mysql学习笔记(三)运算符和控制流函数
  3. JavaEE基础(十四) /正则
  4. Python LOGGING使用方法
  5. HDU-3864 D_num Miller_Rabin和Pollard_rho
  6. HW6.22
  7. shell脚本采用crontab定时备份数据库日志
  8. MySQL查询统计,统计唯一值并分组
  9. 自定义滚动条 niceScroll 配置参数
  10. 《深入了解 Linq to SQL》之对象的标识 —— 麦叔叔呕心呖血之作
  11. MVC不错的学习资料
  12. Java开源内容管理CMS系统J4CMS的几个样式
  13. java面向对象--抽象类和接口
  14. fiddler mock ==&gt; AutoResponder
  15. 【iOS】swift 排序Sort函数用法(包含NSDictionary排序)
  16. svn仓库迁移
  17. linux内核中的linuxPPS是什么?
  18. centos-yum离线源
  19. 页面用一个遮罩层显示加载,加载完后隐藏该div
  20. Egret容器的鼠标默认事件

热门文章

  1. How to select a CRAN mirror in R &amp; use repos parameter(2)
  2. UITextField总结--博主总结的真好
  3. 移动端使用rem方法
  4. boa,thttp服务器安装,配置,测试
  5. “Options模式”下的配置是如何绑定为Options对象
  6. spark install
  7. VS中C++代码折叠
  8. 使用iscroll插件实现下拉刷新功能
  9. 交互设计师谈颠覆式创新 | Think different
  10. 重构HTML改善web应用设计