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-普及组的更多相关文章

  1. 牛客OI周赛9-提高组题目记录

    牛客OI周赛9-提高组题目记录 昨天晚上做了这一套比赛,觉得题目质量挺高,而且有一些非常有趣而且非常清奇的脑回路在里边,于是记录在此. T1: 扫雷 题目链接 设 \(f_i\) 表示扫到第 \(i\ ...

  2. 牛客OI周赛8-提高组A-用水填坑

    牛客OI周赛8-提高组A-用水填坑 题目 链接: https://ac.nowcoder.com/acm/contest/403/A 来源:牛客网 时间限制:C/C++ 2秒,其他语言4秒 空间限制: ...

  3. 牛客OI周赛2-提高组

    A.游戏 链接:https://www.nowcoder.com/acm/contest/210/A来源:牛客网 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 131072K,其他语 ...

  4. 牛客OI周赛11-普及组 B Game with numbers (数学,预处理真因子)

    链接:https://ac.nowcoder.com/acm/contest/942/B 来源:牛客网 Game with numbers 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C+ ...

  5. 牛客OI周赛7-提高组 A 小睿睿的等式

    链接:https://ac.nowcoder.com/acm/contest/371/A来源:牛客网 小睿睿在游戏开始时有n根火柴棒,他想知道能摆成形如“A+B=n”的等式且使用的火柴棒数也恰好等于n ...

  6. 牛客OI周赛7-提高组 B小睿睿的询问(ST打表)

    链接:https://ac.nowcoder.com/acm/contest/371/B来源:牛客网 小睿睿的n个妹纸排成一排,每个妹纸有一个颜值val[i].有m个询问,对于每一个询问,小睿睿想知道 ...

  7. 牛客OI周赛7-普及组 解题报告

    出题人好评. 评测机差评. A 救救喵咪 二位偏序.如果数据范围大的话直接树状数组,不过才1000就\(O(n^2)\)暴力就ok了. #include <bits/stdc++.h> s ...

  8. 牛客OI周赛10-普及组-A眼花缭乱的街市-(加速+二分)

    https://ac.nowcoder.com/acm/contest/901/A 很简单的一道题,全场只有20+AC,卡时间.新学了cin加速语法和数组二分查找的函数调用. 知道有个读写挂,可以加速 ...

  9. 补比赛——牛客OI周赛9-普及组

    比赛地址 A 小Q想撸串 题目分析 普及T1水题惯例.字符串中找子串. Code #include<algorithm> #include<iostream> #include ...

  10. 牛客OI周赛8-普及组

    https://ac.nowcoder.com/acm/contest/543#question A. 代码: #include <bits/stdc++.h> using namespa ...

随机推荐

  1. 【转】MySQL理解索引、添加索引的原则

    索引用于快速找出在某个列中有一特定值的行.不使用索引,MySQL必须从第1条记录开始然后读完整个表直到找出相关的行,还需要考虑每次读入数据页的IO开销.而如果采取索引,则可以根据索引指向的页以及记录在 ...

  2. FFMPEG详细参数

    这几天做视频相关的东西,找到了这款比较牛掰的工具FFmpeg Howto Table of Contents * Generic Syntax * Main Options * Encoding : ...

  3. 【转】Pandas的Apply函数——Pandas中最好用的函数

    转自:https://blog.csdn.net/qq_19528953/article/details/79348929 import pandas as pd import datetime #用 ...

  4. pstart

    下面是我初步的排查过程: [1] [root@71 ~]# tcpdump host 192.168.0.71|grep "IP 115.*"|more tcpdump: verb ...

  5. ESP32 DAC

    ESP32有两个DAC通道,通道1链接GPIO25, 通道2链接GPIO26; 当DAC设置为 “built-in DAC mode”的时候,I2S可以通过DAC发送数据: 使用示例: dac_out ...

  6. C#连接数据库插入数据

    首先是安装JDBC操作数据库的包,,当然自己看着办哈,可以自己下载以后导入,或者直接让软件本身下载 第一种方式 第二种 咱自己下载个低版本的 点击这个链接 点击以后呢可以直接下载下来,然后导入(大家百 ...

  7. php中按值传递和按引用传递的一个问题

    php中传递变量默认是按照值传递. 简单举个例子: <?php function testArray($arr){// &$arr $arr = array(1,2,3,); } $ar ...

  8. python里面 循环明细对比 相同人员明细,生成同一订单里面

    #2018-04-16 def action_create_purc(self,cr,uid,ids,context=None): mrp_origin_obj=self.browse(cr,uid, ...

  9. 如何使用串口来给STM32下载程序

    前言 第一次学习STM32的时候,不知道有调试器这个东西,所以一直是通过串口来给STM32下载程序,下载速度也还算可以,一般是几秒钟完成.后来用了调试器,可以直接在Keil环境下进行下载,而且还可以进 ...

  10. JDK8漫谈——增强接口

    解决什么问题 向下兼容.添加方法,所有的实现类必须实现此方法,否则会编译报错.这意味着每一次的接口升级都会伤筋动骨.但是这是一把双刃剑一定要把握好场景,不要滥用. 类爆炸.使用时,需要辅助类.即要记忆 ...