牛客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のclipToBounds与maskToBounds的区别
UIView.clipsToBounds : 让子 View 只显示父 View 的 Frame 部分,子视图超出frame的部分不显示,默认为NO,设置为YES就会把超出的部分裁掉: maskToB ...
- Android ActionBar全然解析,使用官方推荐的最佳导航栏(上)
转载请注明出处:http://blog.csdn.net/guolin_blog/article/details/18234477 本篇文章主要内容来自于Android Doc.我翻译之后又做了些加工 ...
- 转://使用showplan.sql分析sql Performance
在HelloDBA网站找到一个分析sql性能的工具—showplan,记录一下 showplan.sql下载路径:http://www.HelloDBA.com/Download/showplan.z ...
- YOLO2 (2) 测试自己的数据
Windos10 linux同样过程 现有问题: 本文过程在linux下类似,可以正常通过.windons下,运行python脚本出现问题,无法正常输出0001.txt(标定文件),所以只能使用lin ...
- css3渐变特性
项目中,一般用于业务办理的进度条,设置背景色,纯背景色可以直接设置,如果是渐变色,那使用line-gradient渐变特性就需要设置渐变的位置了入下图 方法一.直接在进度条轨道上面再加一个元素,用于设 ...
- Objective-C @executable_path、@loader_path和@rpath
工程配置中,有三个路径和库的加载息息相关: 1.@executable_path 可执行文件的路径,例如/Applications/WeChat.app/Contents/MacOS. 2.@load ...
- lesson 8:小程序
程序源代码: //20163683 蔡金阳 信1605-3 import java.io.*; import java.util.Scanner; public class kaoshi { publ ...
- kubernetes 集群机器重启后磁盘盘符变化
1.[root@pserver78 ~]# kubectl -n rook-ceph exec -it rook-ceph-tools-c95b8496b-g4stp -- ceph osd tree ...
- 浅谈Java泛型中的extends和super关键字
泛型是在Java 1.5中被加入了,这里不讨论泛型的细节问题,这个在Thinking in Java第四版中讲的非常清楚,这里要讲的是super和extends关键字,以及在使用这两个关键字的时候为什 ...
- eclipse打断点的调试
对于程序员来说,最重要的技能之一其实是在发现问题的时候,定位问题,然后才能解决问题. 发现问题的能力十分的重要.而debug的水平就是基础. 打断点之后,操作相应的步骤,然后eclipse会跳转到相应 ...