牛客OI周赛7-普及组
https://ac.nowcoder.com/acm/contest/372#question
A.救救猫咪
#include <bits/stdc++.h>
using namespace std; const int maxn = 1e5 + ;
int N; struct Node {
int x;
int y;
int cnt;
}node[maxn]; int main() {
scanf("%d", &N);
for(int i = ; i < N; i ++)
scanf("%d%d", &node[i].x, &node[i].y); for(int i = ; i < N; i ++) {
for(int j = ; j < N; j ++) {
if(node[j].x > node[i].x && node[j].y > node[i].y)
node[i].cnt ++;
}
} for(int i = ; i < N; i ++)
printf("%d\n", node[i].cnt);
return ;
}
B.救救兔子
#include <bits/stdc++.h>
using namespace std; const int maxn = 1e5 + ;
int N, M;
int num[maxn]; int main() {
scanf("%d", &N);
for(int i = ; i < N; i ++)
scanf("%d", &num[i]); sort(num, num + N);
scanf("%d", &M);
while(M --) {
int x;
scanf("%d", &x);
int l = , r = N - , mid;
while(l <= r) {
mid = (l + r) / ;
if(x > num[mid]) l = mid + ;
else if(x == num[mid]) break;
else r = mid - ;
}
if(num[mid] == x)
printf("%d\n", num[mid]);
else if(num[mid] > x) {
if(mid == ) printf("%d\n", num[mid]);
else if((num[mid] - x) >= (x - num[mid - ]))
printf("%d\n", num[mid - ]);
else printf("%d\n", num[mid]);
}
else {
if(mid == N - )
printf("%d\n", num[mid]);
else if((num[mid + ] - x) >= (x - num[mid]))
printf("%d\n", num[mid]);
else printf("%d\n", num[mid + ]);
} }
return ;
}
C.救救企鹅
#include <bits/stdc++.h>
using namespace std; string s, a, b; int main() {
cin >> s >> a >> b;
int sign;
sign = s.find(a, );
while(sign != string::npos) {
s.replace(sign, a.size(), b);
sign = s.find(a, sign + );
}
cout << s;
return ;
}
D.数糖纸
#include <bits/stdc++.h>
using namespace std; const int maxn = 1e6 + ;
int N;
int num[maxn];
map<int, int> mp; int main() {
scanf("%d", &N);
for(int i = ; i < N; i ++)
scanf("%d", &num[i]); set<int> s;
int L = , R = , ans = ;
while(R < N) {
while(R < N && !s.count(num[R])) {
s.insert(num[R]);
//mp[num[R]] ++;
R ++;
}
ans = max(ans, R - L);
s.erase(num[L]);
//mp[num[L]] = 0;
L ++;
}
printf("%d\n", ans);
return ;
}
D 题用 map 会超时
牛客OI周赛7-普及组的更多相关文章
- 牛客OI周赛9-提高组题目记录
牛客OI周赛9-提高组题目记录 昨天晚上做了这一套比赛,觉得题目质量挺高,而且有一些非常有趣而且非常清奇的脑回路在里边,于是记录在此. T1: 扫雷 题目链接 设 \(f_i\) 表示扫到第 \(i\ ...
- 牛客OI周赛8-提高组A-用水填坑
牛客OI周赛8-提高组A-用水填坑 题目 链接: https://ac.nowcoder.com/acm/contest/403/A 来源:牛客网 时间限制:C/C++ 2秒,其他语言4秒 空间限制: ...
- 牛客OI周赛2-提高组
A.游戏 链接:https://www.nowcoder.com/acm/contest/210/A来源:牛客网 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 131072K,其他语 ...
- 牛客OI周赛11-普及组 B Game with numbers (数学,预处理真因子)
链接:https://ac.nowcoder.com/acm/contest/942/B 来源:牛客网 Game with numbers 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C+ ...
- 牛客OI周赛7-提高组 A 小睿睿的等式
链接:https://ac.nowcoder.com/acm/contest/371/A来源:牛客网 小睿睿在游戏开始时有n根火柴棒,他想知道能摆成形如“A+B=n”的等式且使用的火柴棒数也恰好等于n ...
- 牛客OI周赛7-提高组 B小睿睿的询问(ST打表)
链接:https://ac.nowcoder.com/acm/contest/371/B来源:牛客网 小睿睿的n个妹纸排成一排,每个妹纸有一个颜值val[i].有m个询问,对于每一个询问,小睿睿想知道 ...
- 牛客OI周赛7-普及组 解题报告
出题人好评. 评测机差评. A 救救喵咪 二位偏序.如果数据范围大的话直接树状数组,不过才1000就\(O(n^2)\)暴力就ok了. #include <bits/stdc++.h> s ...
- 牛客OI周赛10-普及组-A眼花缭乱的街市-(加速+二分)
https://ac.nowcoder.com/acm/contest/901/A 很简单的一道题,全场只有20+AC,卡时间.新学了cin加速语法和数组二分查找的函数调用. 知道有个读写挂,可以加速 ...
- 补比赛——牛客OI周赛9-普及组
比赛地址 A 小Q想撸串 题目分析 普及T1水题惯例.字符串中找子串. Code #include<algorithm> #include<iostream> #include ...
- 牛客OI周赛8-普及组
https://ac.nowcoder.com/acm/contest/543#question A. 代码: #include <bits/stdc++.h> using namespa ...
随机推荐
- WPFの获取屏幕分辨率并自适应
double x = SystemParameters.WorkArea.Width;//得到屏幕工作区域宽度 double y = SystemParameters.WorkArea.Height; ...
- 在linux系统下安装配置apacheserver
我所用的是centos linux系统,但apache的服务在linux系统都大同小异.像ubuntu redhat等等. now let us go! 如有问题, 欢迎直邮: zhe ...
- 转://Oracle补丁及opatch工具介绍
一. CPU(Critical Patch Update) 一个CPU内包含了对多个安全漏洞的修复,并且也包括相应必需的非安全漏洞的补丁.CPU是累积型的,只要安装最新发布的CPU即可,其中包括之前发 ...
- go标准库的学习-crypto/sha1
参考:https://studygolang.com/pkgdoc 导入方式: import "crypto/sha1" sha1包实现了SHA1哈希算法,参见RFC 3174. ...
- 使用 Apache Web 配置多个站点
导读 如何在流行而强大的 Apache Web 服务器上托管两个或多个站点.这篇文章的环境是 Fedora 27 虚拟机,配置了 Apache 2.4.29.如果你用另一个发行版或不同的 Fedora ...
- 项目Alpha冲刺 2
作业描述 课程: 软件工程1916|W(福州大学) 作业要求: 项目Alpha冲刺(团队) 团队名称: 火鸡堂 作业目标: 进行github实战训练,锻炼团队合作能力 1.团队信息 队名:火鸡堂 队员 ...
- 【Codeforces 1132D】Stressful Training
Codeforces 1132 D 题意:给\(n\)个电脑的电量和耗电速度,你可以买一个充电器,它的充电速度是每秒\(v\)单位,\(v\)你自己定.问最小的\(v\)能使得在\(k\)秒内每秒给某 ...
- 【NOIP2017 D1T3】逛公园
NOIP2017 D1T3 逛公园 题意:给一个有向图,每条边有权值,问从\(1\)到\(N\)的长度不超过最短路长度\(+K\)的路径条数.如果有无数条则输出\(-1\). 思路:我们首先扔掉\(- ...
- 《Google软件测试之道》测试工程师
愿和我一样读过这本书的人有所共鸣或者启发,愿没读过这本书的人,能获得一点点收获... 说到软件测试工程师,首先我们需要明白一个问题,软件测试工程师的职责是什么? 关于这个话题,不同的人有不同的定义:抛 ...
- redis make jemalloc
zmalloc.h:50:31: error: jemalloc/jemalloc.h: No such file or directoryzmalloc.h:55:2: error: #error ...