简单说一下。

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. NSArray 迭代

    NSObject *obj=[[NSObject alloc]init];        NSArray *array=[[NSArray alloc] initWithObjects:@" ...

  2. Java API —— Math类

    1.Math类概述         Math 类包含用于执行基本数学运算的方法,如初等指数.对数.平方根和三角函数.  2.成员变量         public static final doubl ...

  3. git跨平台换行符不兼容

    https://help.github.com/articles/dealing-with-line-endings/#platform-all

  4. 购买使用Linode VPS必须知晓的十个问题

    Linode是国外非常著名的VPS商之一,目前在国内站长圈中备受推崇.有许多站长已经购买了Linode VPS,但是部分站长由于中英语言不通,对Linode的政策不了解,从而造成了许多不必要的损失.本 ...

  5. Toad创建DBLINKsop

    Toad创建DBLINKsop 1.创建服务: 点击“测试”,出现如下测试窗口后点击更改登录,用户名和密码数据目标主机用户名.密码; 出现如下窗口后,点击“关闭”,然后点击“完成”即可; 2.创建db ...

  6. Difference between 2>&-, 2>/dev/null, |&, &>/dev/null and >/dev/null 2>&1

    Reference link: http://unix.stackexchange.com/questions/70963/difference-between-2-2-dev-null-dev-nu ...

  7. iOS开发:在Swift中调用oc库

    先列举这个工程中用到的oc源码库: MBProgressHUD:半透明提示器,Loading动画等 SDWebImage:图片下载和缓存的库 MJRefresh: 下拉刷新,上拉加载 Alamofir ...

  8. Vagrant工具

    Vagrant 是一款用来构建虚拟开发环境的工具,非常适合 php/python/ruby/java 这类语言开发 web 应用,“代码在我机子上运行没有问题”这种说辞将成为历史. 我们可以通过 Va ...

  9. 为什么要CGI

    1.微软为什么使用CGI? 微软曾经在不同场合极力推荐它的ASP技术,以取代CGI标准,这对微软当然是有利的,但是对一个网站来说ASP是不是一个明智的选择呢?这是一个值得大家深思熟虑的问题. 因为一旦 ...

  10. 使用AngularJS 进行Hybrid App 开发已经有一年多时间了,这里做一个总结

    一.AngularJS 初始化加载流程 1.浏览器载入HTML,然后把它解析成DOM.2.浏览器载入angular.js脚本.3.AngularJS等到DOMContentLoaded事件触发.4.A ...