牛客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 ...
随机推荐
- 描述整体程序的 app
一个小程序主体部分由三个文件组成,必须放在项目的根目录,如下 app.js文件 App() 函数用来注册一个小程序.接受一个 object 参数,其指定小程序的生命周期函数等.object参数说明如下 ...
- Redis String类型的API使用
package com.daxin.jedis_datastructure; import org.junit.After; import org.junit.Before; import org.j ...
- ROS 双目标定
http://wiki.ros.org/camera_calibration/Tutorials/StereoCalibration 发布ZED节点 roslaunch zed_cpu_ros zed ...
- 对Promise的理解?
ES6原生提供了promise对象 所谓Promise,就是一个对象,用来传递异步操作的消息.它代表了某个未来才会知道结果的事件(通过是一个异步操作),并且这个事件提供统一的API,可供进一步处理 P ...
- mocha测试框架-truffle
https://mochajs.org/ 学习网址: https://www.jianshu.com/p/9c78548caffa https://www.jb51.net/article/10646 ...
- the security of smart contract- 1
https://blog.zeppelin.solutions/the-hitchhikers-guide-to-smart-contracts-in-ethereum-848f08001f05 这个 ...
- 浏览器访问svn
文章转自https://www.cnblogs.com/ayanmw/archive/2011/12/19/2294054.html 你看到的这个文章来自于http://www.cnblogs.com ...
- StringRedisTemplate操作redis数据
StringRedisTemplate与RedisTemplate区别点 两者的关系是StringRedisTemplate继承RedisTemplate. 两者的数据是不共通的:也就是说String ...
- linux简单的安全防护
注: 1.该脚本是以centos7.4.1708做的 2.函数jia/jian是加权限/减权限 3.改过密码以后,下次使用新创建的用户登录时将提示更改密码,第一次要输入原始的密码,原始密码改脚本中定义 ...
- Java:内省(Introspector)
内省(Introspector) 是Java 语言对 JavaBean 类属性.事件的一种缺省处理方法. JavaBean是一种特殊的类,主要用于传递数据信息,这种类中的方法主要用于访问私有的字段,且 ...