牛客国庆集训派对Day4 J-寻找复读机
链接:https://www.nowcoder.com/acm/contest/204/J
来源:牛客网
时间限制:C/C++ 1秒,其他语言2秒
空间限制:C/C++ 1048576K,其他语言2097152K
64bit IO Format: %lld
题目描述
某个 QQ 群里一共有 n 个人,他们的编号是 1..n,其中有一些人本质上是复读机。
小 A 发现,如果一个人的本质是复读机,那么他每次发的消息一定跟群里的上一条消息一样,特别地第一个发消息的人一定不是复读机。
现在小 A 搞到了一份聊天记录,他想请你找出所有可能是复读机的群友
输入描述:
第一行两个正整数 n,m,表示群里的人数和聊天记录的总条数
接下来 m 行按时间顺序给出聊天记录,每行有一个正整数 x 和一个小写字母字符串 S,表示群友 x 发了消息 S
输出描述:
输出一行,将所有可能是复读机的群友的编号按照从小到大排序后输出,每两个编号之间隔一个空格
示例1
输入
3 5
1 gugugu
2 gugugu
1 gugu
3 tingzhifudu
2 tingzhifudu
输出
2
备注:
1≤ n≤ 10^3
1≤ m≤ 10^3
1≤ |S|≤ 100
思路
这题有一个坑点是要找到可能是复读机的群友。所以那些没说过话的也可能是复读机。那么找到已知的一定不是复读机的群友,然后把这些群友排除在外就可以了
AC代码
/*
* @Author: WZY
* @Date: 2018-10-09 16:36:48
* @Last Modified by: WZY
* @Last Modified time: 2018-10-09 17:52:41
*/
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <limits.h>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <string>
#include <time.h>
#define ll long long
#define ull unsigned long long
#define ms(a) memset(a,0,sizeof(a))
#define pi acos(-1.0)
#define INF 0x7f7f7f7f
#define lson o<<1
#define rson o<<1|1
#define debug(...) cerr<<"["<<#__VA_ARGS__":"<<(__VA_ARGS__)<<"]"<<"\n"
const double E=exp(1);
const int maxn=1e6+10;
const int mod=998244353;
using namespace std;
int vis[maxn];
int main(int argc, char const *argv[])
{
ios::sync_with_stdio(false);
#ifndef ONLINE_JUDGE
freopen("in.txt", "r", stdin);
freopen("out.txt", "w", stdout);
double _begin_time = clock();
#endif
int n,m;
cin>>n>>m;
string st1,st2;//st2记录上一个群友说的话
int id;
while(m--)
{
cin>>id>>st1;
// 如果这次的群友和上一个群友说的话一样
if(st1==st2)
continue;
// 如果不一样
vis[id]=1; //表示该id的群友不是复读机
st2=st1; //记录这个群友说的话
}
int _=0;
for(int i=1;i<=n;i++)
{
if(vis[i])
continue;
if(_)
cout<<" ";
else
_++;
cout<<i;
}
cout<<endl;
#ifndef ONLINE_JUDGE
long _end_time = clock();
printf("time = %lf ms.", _end_time - _begin_time);
#endif
return 0;
}
牛客国庆集训派对Day4 J-寻找复读机的更多相关文章
- 牛客国庆集训派对Day4 Solution
A 深度学习 puts(n) #include <bits/stdc++.h> using namespace std; int main() { double n; while ( ...
- 牛客国庆集训派对Day4 I-连通块计数(思维,组合数学)
链接:https://www.nowcoder.com/acm/contest/204/I 来源:牛客网 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 1048576K,其他语言20 ...
- 2018 牛客国庆集训派对Day4 - H 树链博弈
链接:https://ac.nowcoder.com/acm/contest/204/H来源:牛客网 题目描述 给定一棵 n 个点的树,其中 1 号结点是根,每个结点要么是黑色要么是白色 现在小 Bo ...
- 牛客国庆集训派对Day4.B.异或求和(按位统计)
题目链接 刷牛客一战到底做到的,感觉还挺有趣... \(Description\) 求给定\(n\)及序列\(A_i\),求\[\sum_{i\lt j\lt k}(A_i\oplus A_j)(A_ ...
- 线性基求交(2019牛客国庆集训派对day4)
题意:https://ac.nowcoder.com/acm/contest/1109/C 问你有几个x满足A,B集合都能XOR出x. 思路: 就是线性基求交后,有几个基就是2^几次方. #defin ...
- 牛客国庆集训派对Day6 A Birthday 费用流
牛客国庆集训派对Day6 A Birthday:https://www.nowcoder.com/acm/contest/206/A 题意: 恬恬的生日临近了.宇扬给她准备了一个蛋糕. 正如往常一样, ...
- 2019牛客国庆集训派对day5
2019牛客国庆集训派对day5 I.Strange Prime 题意 \(P=1e10+19\),求\(\sum x[i] mod P = 0\)的方案数,其中\(0 \leq x[i] < ...
- 牛客国庆集训派对Day_4~6
Day_4 A.深度学习 题目描述 小 A 最近在研究深度学习,他自己搭建了一个很牛逼的神经网络,现在他手头一共有 n 组训练数据,一开始他会给自己的神经网络设置一个 batch size,假设为 B ...
- 牛客国庆集训派对Day1 L-New Game!(最短路)
链接:https://www.nowcoder.com/acm/contest/201/L 来源:牛客网 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 1048576K,其他语言20 ...
随机推荐
- C#中使用SqlBulkCopy的批量插入和OracleBulkCopy的批量插入
1.首先我们做一下准备工作,在sql server和oracle分别建立一个Student表 oracle中 --创建Student表 -- create table Student( stuId n ...
- linux命令--文件查询
ls [ -lahid ] [ /* ] ls -- 默认查询当前目录下的显性文件 -l -- 显示文件的详细信息 -a -- 显示所有文件(包括隐藏文件) -h -- 文件大小显示为 ...
- Win10系列:UWP界面布局进阶4
在开发Windows应用商店应用程序时,可以为页面中的界面元素添加快捷菜单,并设置与其相关的菜单项,用户通过选择快捷菜单中的菜单项来执行与被选择对象相关的操作.下面通过一个示例来介绍如何为页面中的一张 ...
- Win10系列:JavaScript动画4
上面介绍的动画效果是通过Windows动画库创建的,这里的旋转动画是通过设置页面元素的style对象的相关属性来创建,此动画的效果是将界面元素沿着指定的方向进行旋转.下面介绍style对象的几个常用属 ...
- ROS tab键补全操作出现错误
ros tab键补全操作出现错误如下: $ roslaunch sp[rospack] Warning: error while crawling /home/hemudu: boost::files ...
- 什么是RUP
Rational统一过程(Rational Unified Process,RUP)是由Rational软件公司推出的一种完整且完美的软件过程. RUP总结了经过多年商业化验证的6条最有效的软件开 ...
- CSS学习笔记-04 a标签-导航练习
个人练习,各位大神勿笑 .. <!DOCTYPE html> <html lang="en"> <head> <meta charset ...
- 20165326 学习基础和c语言基础调查
学习基础和c语言基础调查 一.关于个人技能 阅读了娄老师关于做中学的文章,我想起了自己之前学习技能的经历. 从小到大我学过的东西不少,除学校的教育课程外,我还参加过各种兴趣班,书法.绘画.舞蹈.吉他. ...
- 2019.3.5 L261 Are All Our Organs Vital?
Medicine has not always shown a lot of respect for the human body. Just think about the ghoulish dis ...
- kbmMW 5.07.00试用笔记
在kbmMW 5.06.20试用笔记中遇到的问题,在这个版本中,基本都解决了.但还是发现修正后存在的小问题及新问题: 1.Resolve返回值错误 当提交的ClientQuery是执行一条sql语句, ...