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. Topcoder 练习小记,Java 与 Python 分别实现。

    Topcoder上的一道题目,题目描述如下: Problem Statement      Byteland is a city with many skyscrapers, so it's a pe ...

  2. Eclipse - FindBugs Plugin 的安装和使用

    Eclipse -  FindBugs Plugin 的安装和使用 FindBugs is a static analysis tool that examines the classes in se ...

  3. cocos2dx开发笔记

    1.帧动画:SpriteTest=>SpriteAnimationSplit 2.sourceinsight显示代码行 option->document option->editin ...

  4. 《Linux/Unix系统编程手册》读书笔记1

    <Linux/Unix系统编程手册>读书笔记 目录 最近这一个月在看<Linux/Unix系统编程手册>,在学习关于Linux的系统编程.之前学习Linux的时候就打算写关于L ...

  5. Lua for windows中SciTe开启支持python的方法

    打开Options-Open Global Options #import python的#去掉即可

  6. BZOJ 2154 Crash的数字表格

    题目链接:http://61.187.179.132/JudgeOnline/problem.php?id=2154 题意: 思路: i64 mou[N]; void init(int N){    ...

  7. 【Latex】如何在Latex中插入伪代码 —— clrscode3e

    1. 简介clrscode3e是<算法导论(第三版)>使用的伪代码的宏包,clrs其实表示的是Cormen.Leiserson.Rivest和Stein.它有个更老的版本clrscode, ...

  8. mysql if 和 case when 用法 多个when情况用一个语句 存储过程

    在实际开发中,经常会用到 if 和 case when的用法,记录一下,以后可以用得到. DELIMITER $$ USE `数据库`$$ DROPPROCEDUREIFEXISTS `GetNoti ...

  9. hdu 4604 Deque(最长不下降子序列)

    从后向前对已搜点做两遍LIS(最长不下降子序列),分别求出已搜点的最长递增.递减子序列长度.这样一直搜到第一个点,就得到了整个序列的最长递增.递减子序列的长度,即最长递减子序列在前,最长递增子序列在后 ...

  10. Android-取消GridView/ListView item被点击时的效果

    方法一,在控件被初始化的时候设置 gridView.setSelector(new ColorDrawable(Color.TRANSPARENT)); listView.setSelector(ne ...