Codeforces Round #546 (Div. 2)
http://codeforces.com/contest/1136
A
#include <bits/stdc++.h>
using namespace std; const int maxn = 1e5 + ;
int N, K; struct Node {
int L;
int R;
}node[maxn]; int main() {
scanf("%d", &N);
for(int i = ; i <= N; i ++)
scanf("%d%d", &node[i].L, &node[i].R);
scanf("%d", &K); int cnt = ;
for(int i = ; i <= N; i ++) {
if(node[i].R >= K) cnt ++;
else continue;
} printf("%d\n", cnt); return ;
}
B
#include <bits/stdc++.h>
using namespace std; int N, K; int main() {
scanf("%d%d", &N, &K);
int ans = ;
ans = * N + min(K - , N - K);
printf("%d\n", ans);
return ;
}
C (只要判断对角线上的数字就好了 如果对角线数字不同输出 NO)
#include <bits/stdc++.h>
using namespace std; const int maxn = ;
int N, M;
int a[maxn][maxn], b[maxn][maxn];
map<int, int> vis[maxn]; int main() {
scanf("%d%d", &N, &M);
for(int i = ; i <= N; i ++) {
for(int j = ; j <= M; j ++) {
scanf("%d", &a[i][j]);
vis[i + j - ][a[i][j]] ++;
}
}
bool flag = true;
for(int i = ; i <= N; i ++) {
for(int j = ; j <= M; j ++) {
scanf("%d", &b[i][j]);
if(vis[i + j - ][b[i][j]] <= )
flag = false;
vis[i + j - ][b[i][j]] --;
}
} if(flag) printf("YES\n");
else printf("NO\n"); return ;
}
D
#include <bits/stdc++.h>
using namespace std; const int maxn = 3e5 + ;
vector<int> v[maxn];
int N, M;
int num[maxn], ans[maxn]; int main() {
scanf("%d%d", &N, &M);
for(int i = ; i <= N; i ++)
scanf("%d", &num[i]);
while(M --) {
int uu, vv;
scanf("%d%d", &uu, &vv);
v[vv].push_back(uu);
} for(int i = ; i < v[num[N]].size(); i ++)
ans[v[num[N]][i]] ++; int cnt = ;
for(int i = N - ; i >= ; i --) {
if(ans[num[i]] == N - i - cnt) cnt ++;
else {
for(int j = ; j < v[num[i]].size(); j ++)
ans[v[num[i]][j]] ++;
}
} printf("%d\n", cnt);
return ;
}
很久没更新了 最近和队友训练准备这样那样的比赛 写完题好像也没贴 哭唧唧 会尽快把之前做的题总结一下发上来的 养肥我的 Be 客
Codeforces Round #546 (Div. 2)的更多相关文章
- Codeforces Round #546 (Div. 2) 题解
Codeforces Round #546 (Div. 2) 题目链接:https://codeforces.com/contest/1136 A. Nastya Is Reading a Book ...
- Codeforces Round #546 (Div. 2) E 推公式 + 线段树
https://codeforces.com/contest/1136/problem/E 题意 给你一个有n个数字的a数组,一个有n-1个数字的k数组,两种操作: 1.将a[i]+x,假如a[i]+ ...
- Codeforces Round #546 (Div. 2) D 贪心 + 思维
https://codeforces.com/contest/1136/problem/D 贪心 + 思维 题意 你面前有一个队列,加上你有n个人(n<=3e5),有m(m<=个交换法则, ...
- Codeforces Round #546 (Div. 2) ABCDE 题解
1136A: 题意:一本书有n个章节,每个章节的分别在li到ri页,小明读完书后将书折在第k页,问还有多少章节没有读 题解:控制k在li~ri的范围内后输出n-i即可 #include <set ...
- Codeforces Round #546 (Div. 2) B. Nastya Is Playing Computer Games
链接:https://codeforces.com/contest/1136/problem/B 题意: 有n个井盖,每个井盖上有一个小石头. 给出n和k,k表示刚开始在第k个井盖上方. 有三种操作, ...
- Codeforces Round #546 (Div. 2) A. Nastya Is Reading a Book
链接:https://codeforces.com/contest/1136/problem/A 题意: 给n个区间,每个区间范围不超过100,n不超过100. 给一个位置k,1-(k-1)是遍历过的 ...
- Codeforces Round #546 (Div. 2)-D - Nastya Is Buying Lunch
这道题,神仙贪心题... 题意就是我给出数的顺序,并给出多个交换,每个只能用于相邻交换,问最后一个元素,最多能往前交换多少步. 我们考虑这样一个问题,如果一个这数和a[n]发生交换,那么这个数作为后面 ...
- Codeforces Round #546 (Div. 2) C. Nastya Is Transposing Matrices
C. Nastya Is Transposing Matrices time limit per test 1 second memory limit per test 256 megabytes i ...
- Codeforces Round #546 (Div. 2) E - Nastya Hasn't Written a Legend
这题是一个贼搞人的线段树 线段树维护的是 区间和a[i - j] 首先对于update的位置可以二分查找 其次update时候的lazy比较技巧 比如更新的是 l-r段,增加的是c 那么这段的值为: ...
随机推荐
- centos下mysql授予权限提示ERROR 1133 (42000): Can't find any matching row in the user table
错误: 给mysql对应的用户授予权限的时候提示报错: 解决方法: 后面才知道原来是同事这边新增了用户没有flush grant all privileges on *.* to 'user'@'%' ...
- adb 的常见问题与处理办法两三
问题1:无法安装手机驱动, 解决方法:安装强大的豌豆荚,通常能都能解决问题 问题2: adb devices 时出现 adb devicesadb server is out of date. ki ...
- mongoDB python 操作
mongoDB python 操作 import pymongo mongo_client = pymongo.MongoClient(host="127.0.0.1",port= ...
- 设计模式のBuilderPattern(创建者模式)----创建模式
一.产生背景 要组装一台电脑,它的组装过程基本是不变的,都可以由主板.CPU.内存等按照某个稳定方式组合而成.然而主板.CPU.内存等零件本身都是可能多变的.将内存等这种易变的零件与电脑的其他部件分离 ...
- sql 查询所有子节点示例
每天学习一点点 编程PDF电子书.视频教程免费下载:http://www.shitanlife.com/code <!-- 查询机构的所有子机构 --> <select id=&qu ...
- 【转】ffmpeg 常用命令
1. 视频转换 比如一个avi文件,想转为mp4,或者一个mp4想转为ts. ffmpeg -i input.avi output.mp4 ffmpeg -i input.mp4 output.ts ...
- Rsync服务实战
目录 1 安装rsync软件 2 配置 /etc/rsyncd.conf 3 创建用户(运行rsync服务的用户身份) 4 创建虚拟用户密码文件(客户端连接时候使用) 5启动 rsync 服务,并加入 ...
- 【Vuex】mapGetters 辅助函数
mapGetters 辅助函数仅仅是将 store 中的 getter 映射到局部计算属性: import { mapGetters } from 'vuex' export default { // ...
- MySQL 主主配置
一.准备 1.两个数据库版本最好保持一致(因为官方就是这么建议的,主要的问题就是考虑到兼容性问题) 2.连个数据库的数据保持一致,若不一致,可手动调整,比如A比B多一个库,那就将这个库导入到B库,达到 ...
- linux安装mysql5.7.19
0.查看操作系统内核版本 cat /proc/version [admin@octopus-att-d-030098 ~]$ cat /proc/versionLinux version 3.10.0 ...