简单说一下。

A

  搜索出任意一个剩余细胞个数的联通块。剩下的填X。

B

  二分加贪心加数据结构。

/*
* Problem:
* 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 = 100010, MAXM = 100010; int n, m, s, a[MAXM], ai[MAXM], b[MAXN], c[MAXN], bc[MAXN]; bool cmpa(int x, int y) {
return a[x] < a[y];
} bool cmpb(int x, int y) {
return b[x] < b[y];
} class cmpc {
public:
bool operator () (int x, int y) {
return c[x] > c[y];
}
} ; bool check(int x) {
std::priority_queue<int, std::vector<int>, cmpc> pq;//小根堆
int i, j = n, k = 0;
for (i = m; i >= 1; i -= x) {
while (j >= 1 && b[bc[j]] >= a[ai[i]]) {
pq.push(bc[j]);
--j;
}
if (pq.empty())
return 0;
k += c[pq.top()];
pq.pop();
if (k > s)
return 0;
}
return 1;
} void output(int x) {
puts("YES");
std::priority_queue<int, std::vector<int>, cmpc> pq;
int i = m, j = n, k, ans[MAXM];
while (i >= 1) {
while (j >= 1 && b[bc[j]] >= a[ai[i]]) {
pq.push(bc[j]);
--j;
}
for (k = 1; k <= x && i >= 1; ++k, --i)
ans[ai[i]] = pq.top();
pq.pop();
}
for (i = 1; i <= m; ++i)
printf("%d ", ans[i]);
} int main(/*int argc, char **argv*/) {
int i, l, r, mid; scanf("%d%d%d", &n, &m, &s);
for (i = 1; i <= m; ++i) {
scanf("%d", a + i);
ai[i] = i;
}
for (i = 1; i <= n; ++i) {
scanf("%d", b + i);
bc[i] = i;
}
for (i = 1; i <= n; ++i)
scanf("%d", c + i);
std::sort(ai + 1, ai + m + 1, cmpa);
std::sort(bc + 1, bc + n + 1, cmpb);
if (!check(m))
printf("NO");
else {
l = 1;
r = m;
while (l < r) {
mid = (l + r) >> 1;
if (check(mid))
r = mid;
else
l = mid + 1;
}
output(r);
} fclose(stdin);
fclose(stdout);
return 0;
}

C

  贪心,dp,位运算。

/*
* Problem: C. Captains Mode
* 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; int n, m, a[111], d[21], p[1048577], f[1048577];
char c[21]; int main(/*int argc, char **argv*/) {
int i, j, x, y; scanf("%d", &n);
for (i = 1; i <= n; ++i)
scanf("%d", a + i);
std::sort(a + 1, a + n + 1, std::greater<int>());
scanf("%d", &n);
for (i = 1; i <= n; ++i)
scanf(" %c %d", c + i, d + i);
m = (1 << n) - 1;
p[0] = 0;
for (i = 1; i <= m; ++i)
p[i] = p[i >> 1] + (i & 1);
f[m] = 0;
for (i = m - 1; i >= 0; --i) {
f[i] = d[x = p[i] + 1] == 2 ? INT_MAX : INT_MIN;
for (j = 1; j <= n; ++j) {
y = 1 << (j - 1);
if (i & y || f[i ^ y] == INT_MAX || f[i ^ y] == INT_MIN)
continue;
if (d[x] == 1) {
if (c[x] == 'p')
f[i] = std::max(f[i], f[i ^ y] + a[j]);
else
f[i] = std::max(f[i], f[i ^ y]);
} else {
if (c[x] == 'p')
f[i] = std::min(f[i], f[i ^ y] - a[j]);
else
f[i] = std::min(f[i], f[i ^ y]);
}
}
}
printf("%d", f[0]); fclose(stdin);
fclose(stdout);
return 0;
}

D

  官方做法是把l,v,r看成平面上的矩形。用线段树求出重叠数最多的部分。

E

  仔细分析一下,很明显是维护一个下凸,用单调栈即可。

  

Codeforces 377的更多相关文章

  1. Codeforces 377 A Maze【DFS】

    题意:给出n*m的矩阵,矩阵由'.'和'#'组成,再给出k,表示需要在'.'处加k堵墙,使得剩下的'.'仍然是连通的 先统计出这个矩阵里面总的点数'.'为sum 因为题目说了一定会有一个解,所以找到一 ...

  2. Codeforces #377 Div2

    打得还不错的一场CF,题目质量也很高,今后还要继续努力 A题: 题意:给定一个数k,让其乘一个最小的数,使乘得以后的数要不被10整除,要不减去r以后被10整除,求这个最小的数 #include < ...

  3. Codeforces Round #377 (Div. 2) D. Exams

    Codeforces Round #377 (Div. 2) D. Exams    题意:给你n个考试科目编号1~n以及他们所需要的复习时间ai;(复习时间不一定要连续的,可以分开,只要复习够ai天 ...

  4. Codeforces Round #377 (Div. 2)D(二分)

    题目链接:http://codeforces.com/contest/732/problem/D 题意: 在m天中要考k个课程, 数组a中有m个元素,表示第a[i]表示第i天可以进行哪门考试,若a[i ...

  5. Codeforces Round #377 (Div. 2) E. Sockets

    http://codeforces.com/contest/732/problem/E 题目说得很清楚,每个电脑去插一个插座,然后要刚好的,电脑的power和sockets的值相同才行. 如果不同,还 ...

  6. Codeforces Round #377 (Div. 2) D. Exams 贪心 + 简单模拟

    http://codeforces.com/contest/732/problem/D 这题我发现很多人用二分答案,但是是不用的. 我们统计一个数值all表示要准备考试的所有日子和.+m(这些时间用来 ...

  7. Codeforces Round #377 (Div. 2) 被坑了

    http://codeforces.com/contest/732/problem/B 题目要求任意两个连续的日子都要 >= k 那么如果a[1] + a[2] < k,就要把a[2]加上 ...

  8. Codeforces Round #377 (Div. 2)A,B,C,D【二分】

    PS:这一场真的是上分场,只要手速快就行.然而在自己做的时候不用翻译软件,看题非常吃力非常慢,还有给队友讲D题如何判断的时候又犯了一个毛病,一定要心平气和,比赛也要保证,不要用翻译软件做题: Code ...

  9. Codeforces Round #377 (Div. 2)

    #include <iostream> #include <stdio.h> #include <string.h> using namespace std; in ...

随机推荐

  1. (转)MyEclipse +Servlet

    来自:http://www.cnblogs.com/sunada2005/p/3520788.html 在Win7系统下运行自己的第一个Servlet程序,因为有时候配置不当或系统原因可能会运行不成功 ...

  2. C++异常以及异常与析构函数

    1. 抛出异常 1.1 抛出异常(也称为抛弃异常)即检测是否产生异常,在C++中,其采用throw语句来实现,如果检测到产生异常,则抛出异常. 该语句的格式为: throw 表达式; 如果在try语句 ...

  3. UVa 1453 - Squares 旋转卡壳求凸包直径

    旋转卡壳求凸包直径. 参考:http://www.cppblog.com/staryjy/archive/2010/09/25/101412.html #include <cstdio> ...

  4. hadoop-0.23.9安装以及第一个mapreduce测试程序

    hadoop是一个能够对大量数据进行分布式处理的软件框架.它实现了一个分布式文件系统(Hadoop Distributed File System),简称HDFS.HDFS有着高容错性的特点,并且设计 ...

  5. FileObverse文件观察者的Debug报告

    FileObverse文件观察者的Debug报告 2014年9月18日 9:03

  6. sdut 2934 人活着系列之平方数 (完全背包变形)

    题目链接 分析:完全背包的变形,每一层的d[]数组代表这一层的这个数新加入以后所构成的val的种类. #include <iostream> #include <cstdio> ...

  7. jquery ajax请求 清除缓存

    使用jquery里load方法或者ajax调用页面的时候会存在cache的问题,清除cache的方法: 调用jQuery.ajaxSetup ({cache:false}) 方法即可.

  8. WTL汉化版2013.10.15

    汉化内容: 2013.10.15 版本:当前可下载Trunk最新版,wtl-code-467-trunk.zip 汉化内容: 1.应用向导的部分汉化,考虑到部分词汇的表述问题,只汉化无影响部分 2.资 ...

  9. noip2008提高组题解

    第一题:笨小猴 模拟   第二题:火柴棒等式 搜索 深搜不用说,确定出两个加数然后判断能否拼出等式. 枚举确实不太好搞,因为枚举范围不确定,太大了容易超时,太小了容易漏解.不过这题的数据貌似很温和,我 ...

  10. 查看nginx编译安装

    大家是否遇到过去了新公司,公司内的LAMP,LNMP等所有的环境都是配置好的(已经在提供服务了),公司又没有留下部署文档,甚至安装LAMP,LAMP等环境的人已经和你交接完离职了,那么线上服务器(la ...