A:

题目大意:给你$a,b,c$三条边,可以给任意的边加任意的长度,求最少共加多少长度使得可以构成三角形

题解:排个序,若可以组成,输出$0$,否则输出$c-a-b+1(设a\leqslant b\leqslant c)$

卡点:

C++ Code:

#include <cstdio>
#include <algorithm>
#include <cstring>
#include <queue>
inline int min(int a, int b) {return a < b ? a : b;}
inline int max(int a, int b) {return a > b ? a : b;} int n, m;
int a[5];
int main() {
for (int i = 0; i < 3; i++) scanf("%d", a + i);
std::sort(a, a + 3);
if (a[0] + a[1] > a[2]) {
puts("0");
} else {
printf("%d\n", a[2] - a[0] - a[1] + 1);
}
return 0;
}

  

B:

题目大意:给你一个数$a(0\leqslant a\leqslant2^{30}-1$,问有多少个数$x(0\leqslant x\leqslant2^{30}-1)$满足$a-(a\oplus x)-x=0$。多组询问

题解:发现满足若$a-(a\oplus x)-x=0$,则$a=(a\oplus x)+x$,即$((a\oplus x)|x)+((a\oplus x)\&x)=a$,若$a$的某一位为$0$,则$x$该位必须为$1$,若为$1$,$x$该位$1,0$均可。所以$ans=2^{\_\_builtin\_popcount(a)}$

卡点:

C++ Code:

#include <cstdio>
#include <algorithm>
#include <cstring>
inline int min(int a, int b) {return a < b ? a : b;}
inline int max(int a, int b) {return a > b ? a : b;} int n, m, Tim;
long long a, ans;
int main() {
scanf("%d", &Tim);
while (Tim --> 0) {
scanf("%I64d", &a);
ans = 1;
for (long long i = 0; i < 31; i++) {
if (a & (1ll << i)) {
ans *= 2;
}
}
printf("%I64d\n", ans);
}
return 0;
}

  

C:

题目大意:给你一个字符串,要求你把它重排,使得重排后的字符串的回文字串最多

题解:把原字符串排序,发现这样每一段的回文字串个数是平方级别的,猜测这样最多,然后就过了

卡点:

C++ Code:

#include <cstdio>
#include <algorithm>
#include <cstring>
#include <queue>
inline int min(int a, int b) {return a < b ? a : b;}
inline int max(int a, int b) {return a > b ? a : b;} int n, m;
char s[100010];
int main() {
scanf("%d", &n);
scanf("%s", s + 1);
std::sort(s + 1, s + n + 1);
printf("%s\n", s + 1);
return 0;
}

  

D:

题目大意:给你一个$n\times m$的矩阵,其中"*"表示墙,"."表示空地,你最多可以按$x$次左和$y$次右,上下没有限制,问最多可以到达几个点

题解:$bfs$,考虑对于到达一个点的不同状态,一定有一个$x,y$比其他的均优(因为要向左一定要向右),可以用优先队列保存(上下的优先级比较高)。

卡点:以为先到达的一定优,于是用普通队列,然后$FST$

C++ Code:

#include <cstdio>
#include <algorithm>
#include <cstring>
#include <queue>
const int z[2][4] = {{1, 0, -1, 0}, {0, 1, 0, -1}};
inline int min(int a, int b) {return a < b ? a : b;}
inline int max(int a, int b) {return a > b ? a : b;} int n, m, r, c, a, b;
char s[2010][2010]; struct node {
int x, y, a, b;
inline bool operator < (const node &rhs) const {return a < rhs.a;}
inline node(int __x = 0, int __y = 0, int __a = 0, int __b = 0) {x = __x, y = __y, a = __a, b = __b;}
};
std::priority_queue<node> q;
bool inq[2010][2010];
inline bool yj(int x, int y) {
if (x < 1 || x > n || y < 1 || y > m) return true;
if (s[x][y] != '.') return true;
return false;
}
int ans;
void bfs(int __x, int __y) {
q.push(node(__x, __y, a, b));
while (!q.empty()) {
node u = q.top(); q.pop();
if (inq[u.x][u.y]) continue;
ans++;
inq[u.x][u.y] = true;
for (int i = 0; i < 4; i++) {
int x = u.x + z[0][i], y = u.y + z[1][i];
if (yj(x, y)) continue;
node tmp = node(x, y, u.a, u.b);
if (i == 1) tmp.b--;
if (i == 3) tmp.a--;
if (tmp.a < 0 || tmp.b < 0) continue;
q.push(tmp);
}
}
}
int main() {
scanf("%d%d", &n, &m);
scanf("%d%d", &r, &c);
scanf("%d%d", &a, &b);
for (int i = 1; i <= n; i++) {
scanf("%s", s[i] + 1);
}
bfs(r, c);
printf("%d\n", ans);
return 0;
}

  

E:

题目大意:交互题。给定一个平面(横、纵坐标均在[0,10^9]之间)。有$n(n\leqslant 30)$个点,每个点都为黑色或白色。但你不知道点的颜色。

要你依次给出点的位置,你选择一个点的位置,交互库给你它的颜色。要求最后输出一条直线,将平面分成$2$部分,使得每部分的点的颜色相同(不能有点落在直线上)。

所有的点的坐标都是整数。

题解:二分答案,第一个点放在最左边,如果一个点和第一个点一样,下一个点就向右移,否则向左移。

卡点:被卡精度,直线经过一个点,$FST$

C++ Code:

#include <cstdio>
#include <algorithm>
#include <cstring>
#include <queue>
inline int min(int a, int b) {return a < b ? a : b;}
inline int max(int a, int b) {return a > b ? a : b;} int n, m, l, r;
char s[10];
int get(char *s) {
if (s[0] == 'b') return 1;
return 0;
}
void put(int x, int y) {
printf("%d %d\n", x, y);
fflush(stdout);
fflush(stdin);
}
int main() {
scanf("%d", &n);
l = 0, r = 1000000000;
put(0, 0);
scanf("%s", s);
int op = get(s);
for (int i = 1; i < n; i++) {
int mid = (l + r + 1) >> 1;
put(mid, mid);
scanf("%s", s);
if (op == get(s)) l = mid;
else r = mid;
}
printf("%d %d %d %d\n", l, l + 1, l + 1, l);
return 0;
}

  

[Codeforces Round #516 (Div. 2, by Moscow Team Olympiad) ](A~E)的更多相关文章

  1. Codeforces Round #516 (Div. 2, by Moscow Team Olympiad) D. Labyrinth

    http://codeforces.com/contest/1064/problem/D 向上/向下加0,向左/右加1, step = 0,1,…… 求的是最少的步数,所以使用bfs. step=k ...

  2. Codeforces Round #516 (Div. 2, by Moscow Team Olympiad) D. Labyrinth(重识搜索)

    https://codeforces.com/contest/1064/problem/D 题意 给你一个有障碍的图,限制你向左向右走的次数,问你可以到达格子的个数 思路 可以定义状态为vi[x][y ...

  3. Codeforces Round #516 (Div. 2, by Moscow Team Olympiad)

    题目链接 A. Make a triangle! 题意 让某段最少增加多少使得构成三角形 思路 让较小两段往最长段去凑 代码 #include <bits/stdc++.h> #defin ...

  4. Codeforces Round #441 (Div. 2, by Moscow Team Olympiad) D. Sorting the Coins

    http://codeforces.com/contest/876/problem/D 题意: 最开始有一串全部由"O"组成的字符串,现在给出n个数字,指的是每次把位置n上的&qu ...

  5. Codeforces Round #441 (Div. 2, by Moscow Team Olympiad) C. Classroom Watch

    http://codeforces.com/contest/876/problem/C 题意: 现在有一个数n,它是由一个数x加上x每一位的数字得到的,现在给出n,要求找出符合条件的每一个x. 思路: ...

  6. Codeforces Round #441 (Div. 2, by Moscow Team Olympiad) B. Divisiblity of Differences

    http://codeforces.com/contest/876/problem/B 题意: 给出n个数,要求从里面选出k个数使得这k个数中任意两个的差能够被m整除,若不能则输出no. 思路: 差能 ...

  7. Codeforces Round #441 (Div. 2, by Moscow Team Olympiad) A. Trip For Meal

    http://codeforces.com/contest/876/problem/A 题意: 一个人一天要吃n次蜂蜜,他有3个朋友,他第一次总是在一个固定的朋友家吃蜂蜜,如果说没有吃到n次,那么他就 ...

  8. Codeforces Round #441 (Div. 2, by Moscow Team Olympiad)

    A. Trip For Meal 题目链接:http://codeforces.com/contest/876/problem/A 题目意思:现在三个点1,2,3,1-2的路程是a,1-3的路程是b, ...

  9. CF Round #516 (Div. 2, by Moscow Team Olympiad)

    前言:依旧菜,\(A\)了\(4\)题,不过这次上蓝了挺开心的. A. Make a triangle! Description 给出\(3\)根木棍,希望用它们拼成三角形,可以将其中的某些木棍增长, ...

随机推荐

  1. 小程序weapp的状态管理 Wenaox

    Wenaox wechat state management 特点 支持中间件 中大型项目可多个 contro 区分模块 asyncs 自带 loading 轻量.性能好 安装 npm i -S we ...

  2. 《JSON笔记之二》----封装JSONUtil

    许多java开发人员对于fastjson再也熟悉不过了,这是alibaba开源的依赖,使用fastjson可以使我们很容易的把请求json串转换成为我们所需要的对象.list.map等对象格式,对于开 ...

  3. docker启用镜像常用脚本

    语法:docker run [OPTIONS] IMAGE [COMMAND] [ARG...] OPTIONS说明:-a stdin: 指定标准输入输出内容类型,可选 STDIN/STDOUT/ST ...

  4. hasOwnProperty自我理解

    暂时不考虑ES6中symbol,hasOwnProperty()方法返回的是一个对象上是否包含一个指定属性,如果含有则返回true,如果没有则返回false.   和 in 运算符不同,该方法会忽略掉 ...

  5. LeetCode970. 强整数

    问题:970. 强整数 用户通过次数0 用户尝试次数0 通过次数0 提交次数0 题目难度Easy 给定两个非负整数 x 和 y,如果某一整数等于 x^i + y^j,其中整数 i >= 0 且  ...

  6. (转)数据库老兵:NewSQL才是未来

    编者按:在数据库技术领域,Michael Stonebraker几乎是无人不知无人不晓的人物.现年70岁的Stonebraker不仅是Ingres和PostgreSQL的创始人,同时在Informix ...

  7. HTML5--定义区块

    1.效果图如下: 备注: <article> 1.作用:用来表示文档.页面中独立的.完整的.可以独自被外部引用的内容 2.一般有个header元素,有时还有脚注 <article&g ...

  8. java中substring()、charAt()、indexOf() (2013-05-05-bd 写的日志迁移

    substring 1. public String substring(int beginIndex)     返回一个新的字符串,它是此字符串的一个子字符串, 该子字符串始于指定索引处的字符,一直 ...

  9. python3爬取咪咕音乐榜信息(附源代码)

    参照上一篇爬虫小猪短租的思路https://www.cnblogs.com/aby321/p/9946831.html,继续熟悉基础爬虫方法,本次爬取的是咪咕音乐的排名 咪咕音乐榜首页http://m ...

  10. 1、spring boot入门

    1.Spring Boot 简介 简化Spring应用开发的一个框架: 整个Spring技术栈的一个大整合: J2EE开发的一站式解决方案: 2.微服务 2014,martin fowler 微服务: ...