A

  7的所有的余数都可以用1,6,8,9排列得到,然后搞一下就可以了。

B

  可以用类似于单调队列的东西搞。具体看代码:

/*
* Problem: B. Maximum Submatrix 2
* Author: Shun Yao
* Note: 题目要求交换行,我写的交换列。于是把矩阵转换一下就可以。
*/ #include <string.h>
#include <stdlib.h>
#include <limits.h>
#include <assert.h>
#include <stdio.h>
#include <ctype.h>
#include <math.h>
#include <time.h> #include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <string>
#include <vector>
#include <bitset>
#include <utility>
#include <iomanip>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional> //using namespace std; const int MAXN = 5010, MAXM = 5010; int n, m, a[MAXN][MAXM], f[MAXN][MAXM];
char s[MAXN][MAXM]; int main(/*int argc, char **argv*/) {
int i, j, k, l, ans; // freopen("B.in", "r", stdin);
// freopen("B.out", "w", stdout); scanf("%d%d", &n, &m);
for (i = 1; i <= n; ++i)
scanf(" %s", s[i] + 1);
ans = 0;
for (i = 1; i <= n; ++i) {
a[0][i] = i;
f[0][i] = 0;
}
for (i = 1; i <= m; ++i) {
l = 0;
for (j = 1; j <= n; ++j) {
k = a[i - 1][j];
if (s[k][i] == '1') {
f[i][k] = f[i - 1][k] + 1;
a[i][++l] = k;
ans = std::max(ans, f[i][k] * l);
} else
f[i][k] = 0;
}
for (j = 1; j <= n; ++j)
if (f[i][j] == 0)
a[i][++l] = j;
}
printf("%d", ans); fclose(stdin);
fclose(stdout);
return 0;
}

C

  题目中实际上有提示,用dp[i][j][k]表示在(i, j),过所有object的射线的奇偶性为k的最小步数。

/*
* Problem: C. Circling Round Treasures
* Author: Shun Yao
*/ #include <string.h>
#include <stdlib.h>
#include <limits.h>
#include <assert.h>
#include <stdio.h>
#include <ctype.h>
#include <math.h>
#include <time.h> #include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <string>
#include <vector>
#include <bitset>
#include <utility>
#include <iomanip>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional> //using namespace std; const int MAXN = 22, MAXM = 22, dx[4] = {0, 0, 1, -1}, dy[4] = {1, -1, 0, 0}; int n, m, a[MAXN][MAXM], sum[333], f[MAXN][MAXM][333];
char s[MAXN][MAXM]; class Data {
public:
int x, y, k;
Data(int X, int Y, int K) : x(X), y(Y), k(K) {}
} ; std::queue<Data> q; int main(/*int argc, char **argv*/) {
int bomb, object, tl, i, j, k, x, y, trea[10], treasure[10], sx, sy, xx, yy, kk, ans; scanf("%d%d", &n, &m);
for (i = 1; i <= n; ++i)
scanf(" %s", s[i] + 1);
bomb = 0;
object = 0;
tl = 0;
for (i = 1; i <= n; ++i)
for (j = 1; j <= m; ++j) {
switch (s[i][j]) {
case 'B':
++object;
bomb += 1 << (object - 1);
for (k = 1; k <= i; ++k)
a[k][j] += 1 << (object - 1);
break;
case 'S':
s[i][j] = '.';
sx = i;
sy = j;
break;
case '.':
break;
case '#':
break;
default:
++tl;
++object;
trea[s[i][j] - '0'] = 1 << (object - 1);
for (k = 1; k <= i; ++k)
a[k][j] += 1 << (object - 1);
}
}
for (i = 1; i <= tl; ++i)
scanf("%d", &treasure[i]);
for (i = 0; i < 1 << object; ++i)
if ((i & bomb) == 0)
for (j = 1; j <= tl; ++j)
if (i & trea[j])
sum[i] += treasure[j];
//bfs-----------------------------------------------------------------------
memset(f, -1, sizeof f);
f[sx][sy][0] = 0;
q.push(Data(sx, sy, 0));
ans = 0;
while (!q.empty()) {
x = q.front().x;
y = q.front().y;
k = q.front().k;
q.pop();
if (x == sx && y == sy)
ans = std::max(ans, sum[k] - f[x][y][k]);
for (i = 0; i < 4; ++i) {
xx = x + dx[i];
yy = y + dy[i];
if (xx < 1 || xx > n || yy < 1 || yy > m || s[xx][yy] != '.')
continue;
kk = k;
if (i == 0)
kk ^= a[xx][yy];
if (i == 1)
kk ^= a[x][y];
if (f[xx][yy][kk] == -1) {
f[xx][yy][kk] = f[x][y][k] + 1;
q.push(Data(xx, yy, kk));
}
}
}
printf("%d", ans); fclose(stdin);
fclose(stdout);
return 0;
}

D

  启发式合并平衡树 或者 莫队算法(其实dfs后分块做也可以)。

E

  官方给的是线性规划。dp也可以过。

Codeforces 375的更多相关文章

  1. Codeforces 375 D Tree and Queries

    Discription You have a rooted tree consisting of n vertices. Each vertex of the tree has some color. ...

  2. Codeforces Round #375 (Div. 2) - D

    题目链接:http://codeforces.com/contest/723/problem/D 题意:给定n*m小大的字符矩阵.'*'表示陆地,'.'表示水域.然后湖的定义是:如果水域完全被陆地包围 ...

  3. Codeforces Round #375 (Div. 2) - C

    题目链接:http://codeforces.com/contest/723/problem/C 题意:给定长度为n的一个序列.还有一个m.现在可以改变序列的一些数.使得序列里面数字[1,m]出现次数 ...

  4. Codeforces Round #375 (Div. 2) - B

    题目链接:http://codeforces.com/contest/723/problem/B 题意:给定一个字符串.只包含_,大小写字母,左右括号(保证不会出现括号里面套括号的情况),_分隔开单词 ...

  5. Codeforces Round #375 (Div. 2) - A

    题目链接:http://codeforces.com/contest/723/problem/A 题意:在一维坐标下有3个人(坐标点).他们想选一个点使得他们3个到这个点的距离之和最小. 思路:水题. ...

  6. Codeforces Round #375 (Div. 2) F. st-Spanning Tree 生成树

    F. st-Spanning Tree 题目连接: http://codeforces.com/contest/723/problem/F Description You are given an u ...

  7. Codeforces Round #375 (Div. 2) E. One-Way Reform 欧拉路径

    E. One-Way Reform 题目连接: http://codeforces.com/contest/723/problem/E Description There are n cities a ...

  8. Codeforces Round #375 (Div. 2) D. Lakes in Berland 贪心

    D. Lakes in Berland 题目连接: http://codeforces.com/contest/723/problem/D Description The map of Berland ...

  9. Codeforces Round #375 (Div. 2) B. Text Document Analysis 模拟

    B. Text Document Analysis 题目连接: http://codeforces.com/contest/723/problem/B Description Modern text ...

随机推荐

  1. Redhat 使用中文安装后更换为英文的设定

    vi /etc/sysconfig/i18n将LANG改为LANG=en_US.UTF-8保存退出,重新reboot

  2. Flash上传文件(结合asp.net)

    一.实现原理.在某些场合,我们需要使用Flash进行“文件上传”,原因是Flash 能制作出表现力丰富的UI界面. (自负又孤陋寡闻的我在这里做一个补充:Flash使用flash.net包中的File ...

  3. HDU 4358 Boring counting 树状数组+思路

    研究了整整一天orz……直接上官方题解神思路 #include <cstdio> #include <cstring> #include <cstdlib> #in ...

  4. nand flash 扇区的管理以及初始化

    (1)首先需要了解NAND FLASH的结构.如图: 以镁光MT29F4G08BxB Nand Flash为例,这款Flash(如上图)以4个扇区(sector)组成1个页(page),64个页(pa ...

  5. rundeck email配置文件配置

    最近工作中用到了一个任务管理软件rundeck,其中有个很重要的功能就是任务执行提醒,用邮件执行,其中一些配置项,官网没有详细的说明,在网上也没有一个整体的说明,在次跟大家共享下,rundeck的使用 ...

  6. static,this,抽象类,接口和包

    1. static 1)静态变量:Java虚拟机为静态变量开辟单独的存储空间,所以所有的对象内部的静态变量在内存中都指向同一个地址,那么不管哪个对象改变这个成员变量,所有对象中该成员变量的值都发生变化 ...

  7. SQL全文搜索

    ( select dd.*,t.RANK from crm_CustomerAnalyzeDetails dd ) as t on dd.ID = t.[key] ) union all ( sele ...

  8. UVa 10817 (状压DP + 记忆化搜索) Headmaster's Headache

    题意: 一共有s(s ≤ 8)门课程,有m个在职教师,n个求职教师. 每个教师有各自的工资要求,还有他能教授的课程,可以是一门或者多门. 要求在职教师不能辞退,问如何录用应聘者,才能使得每门课只少有两 ...

  9. [swustoj 785] Divide Tree

    Divide Tree(0785) 问题描述 As we all know that we can consider a tree as a graph. Now give you a tree wi ...

  10. 原创:js代码, 让dedecms支持Tag选择, 添加内容更为方便,不用手输Tag

    dedecms在编辑修改内容时,TAG标签需要手动输,中文的Tag, 中间还得用半角字符','分隔,  输入法切来切去很不方便,   于是动手改后台代码, 利用后台的tags_main.php, 让d ...