#366 A-C
A. Hulk
题意是给你一个n 输出一个英文字符串,找下规律就发现
当(i!=n&&i%2==1) 输出的是 I hate that (注意大写)
当(i!=n&&i%2==0) 输出的是 I love that (注意大写)
当(i==n&&i%2==1) 输出的是 I love it (注意大写)
当(i==n&&i%2==0) 输出的是 I love it (注意大写)
注意有空格;
#include<bits/stdc++.h>
#define int long long
#define MAX(a,b,c) max(a,max(b,c))
#define MIN(a,b,c) min(a,min(b,c))
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef long long LL;
typedef unsigned long long ull;
typedef unsigned long long uLL;
using namespace std;
const int maxn=1e5+;
const int INF=0x3f3f3f3f;
int32_t main()
{
int n; cin>>n;
for(int i=;i<n;i++)
{
if(i%==) cout<<"I hate that"<<" ";
else cout<<"I love that"<<" ";
}
if(n%==) cout<<"I hate it"<<endl;
else cout<<"I love it"<<endl;
}
A.cpp
B. Spider Man
题意有点难,每次给你以一个数n 让你去操作 输出结果;
每次操作是找一个圈 长度为x>=2 分成1-p p-两段
每个n 要去到 n-1 个点
n为偶数时 首次可以去掉 0 2 个点 第一个操作者可以操作最后一下,第一个操作者win
当n为奇数时候 首次每次只能去掉1个点 就变成了奇数+偶数 第一个操作者 lost
#include<bits/stdc++.h>
#define int long long
#define MAX(a,b,c) max(a,max(b,c))
#define MIN(a,b,c) min(a,min(b,c))
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef long long LL;
typedef unsigned long long ull;
typedef unsigned long long uLL;
using namespace std;
const int maxn=1e5+;
const int INF=0x3f3f3f3f;
int32_t main()
{
int n; cin>>n; int t=;
for(int i=;i<=n;i++)
{
int x; cin>>x;
if(x%==) cout<<t<<endl;
else
{
if(t==) t=;
else t=;
cout<<t<<endl;
}
}
}
B.cpp
C. Thor
题目意思就是n个程序发送手机通知 ,你去查看通知,问你每次剩下多少通知没看
有3种类型
type 1 应用 b 发送一个通知;
type 2 阅读 b 的所有通知;
type 3 阅读前t个通知(可以重复阅读)
直接暴力肯定过不了 n*p 复杂度过不去
我们注意 单独的type2 type3 都可以用o(n)的复杂度过去
我们就要把这两个联系在一起
执行type2操作时 我们要去重(type3操过的 (一前type2操作))
单独的type2时 每次type2时 总数减去 新加的amout[b] ;
新加的mount[b] 中可能有type3操作过的; 我们要在type中减去;
执行type3操作时候 遍历上一次 t1到这次的;
中间有type2读过的 所以要type2要标记位置,使type3遍历时候跳过这个数
#include<bits/stdc++.h>
#define int long long
#define MAX(a,b,c) max(a,max(b,c))
#define MIN(a,b,c) min(a,min(b,c))
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef long long LL;
typedef unsigned long long ull;
typedef unsigned long long uLL;
using namespace std;
const int maxn=3e5+;
const int INF=0x3f3f3f3f;
vector<int> vs[maxn];
pair<int,int> pa[maxn];
int amout[maxn];
int pos[maxn];
int32_t main()
{
int n,q; cin>>n>>q;
int cnt=,sum=;
int p=;
for(int i=;i<q;i++)
{
int a,b; cin>>a>>b;
if(a==)
{
vs[b].pb(cnt);
amout[b]++;
sum++;
pa[cnt].first=;
pa[cnt].second=b;
cnt++;
}
if(a==)
{
sum=sum-amout[b];
amout[b]=;
for(int j=pos[b];j<vs[b].size();j++)
{
pa[vs[b][j]].first=;
}
pos[b]=vs[b].size();
}
if(a==)
{
for(int j=p;j<b;j++)
{
if(!pa[j].first)
{
pa[j].first=;
sum--;
amout[pa[j].second]--;
}
}
p=max(p,b);
}
cout<<sum<<endl;
} }
C.cpp
#366 A-C的更多相关文章
- Codeforces Round #366 (Div. 2) ABC
Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate ...
- <Tree> 298 250 366 199(高频) 98(高频)
298. Binary Tree Longest Consecutive Sequence 先序遍历,根左右.如果该节点的 value == 父节点value + 1, 则长度+1; 否则重置为1. ...
- Codeforces Round #366 (Div. 2)
CF 复仇者联盟场... 水题 A - Hulk(绿巨人) 输出love hate... #include <bits/stdc++.h> typedef long long ll; co ...
- 366. Find Leaves of Binary Tree
Given a binary tree, collect a tree's nodes as if you were doing this: Collect and remove all leaves ...
- LintCode 366 Fibonacci
/* 1st method will lead to time limit *//* the time complexity is exponential sicne T(n) = T(n-1) + ...
- Codeforces Round #366 Div.2[11110]
这次出的题貌似有点难啊,Div.1的Standing是这样的,可以看到这位全站排名前10的W4大神也只过了AB两道题. A:http://codeforces.com/contest/705/prob ...
- Codeforces Round #366 (Div. 2) B
Description Peter Parker wants to play a game with Dr. Octopus. The game is about cycles. Cycle is a ...
- Codeforces Round #366 (Div. 2) C 模拟queue
C. Thor time limit per test 2 seconds memory limit per test 256 megabytes input standard input outpu ...
- Codeforces Round #366 (Div. 2) B 猜
B. Spider Man time limit per test 2 seconds memory limit per test 256 megabytes input standard input ...
- Codeforces Round #366 (Div. 2) A
A. Hulk time limit per test 1 second memory limit per test 256 megabytes input standard input output ...
随机推荐
- css3 min-content,max-content,fit-content, fill属性
css3里有四个属性,用来实现以内容为主的尺寸计算方式,intrinsic sizing min-content max-content fit-content fill 其中 fill 关键字,需要 ...
- 使用ES6的reduce函数,根据key去重
最近很着迷于ES6的函数,让代码变得更优雅.ES6里的reduce函数,平时用的不是特别多,真正用起来发现还是挺好用的. 想要实现的效果为: 原数组: let rawArr = [{id:'123'} ...
- Python Django 之 静态文件存放设置
一.静态文件存放路径设置STATICFILES_DIRS 1.在django项目目录下面新建静态文件保存目录 2.在setting中添加相应寻找静态文件目录的配置 STATICFILES_DIRS=( ...
- Win10访问不到XP共享的解决:
不知道别人的是怎么解决. 反正我这么解决了. 我的win10笔记本,是使用windows帐户登陆的.可以同步很多东西. 同事的电脑是台式老古董XP. 扫描不到网上邻居,手动\\ip也访问不到. 最后安 ...
- dede织梦调取一二三级栏目名及栏目下的内容列表的方法
网站根据需要,把地区划成省-市-文章的层级结构,栏目首页需要显示的是 复制代码代码如下: {dede:channelarclist} <!--省显示--> <a href=" ...
- Linux 目录配置标准:FHS
目录 应放置内容 /bin 和/user/目录下的/bin/都是用来保存的系统命令 /sbin 和/user/目录下的/sbin是用来保存root的系统命令 /boot 这个目录主要放置开机所用的文件 ...
- (C/C++学习笔记) 三. 作用域和可见性
三. 作用域和可见性 ● 标识符的作用域 标识符的作用域是标识符在程序源代码中的有效范围,从小到大分为函数原型作用域.块作用域(局部作用域),文件作用域(全局作用域). 1. 函数原型作用域 函数原型 ...
- 安装babel
http://jamesknelson.com/using-es6-in-the-browser-with-babel-6-and-webpack/
- SQL-32 将employees表的所有员工的last_name和first_name拼接起来作为Name,中间以一个空格区分
题目描述 将employees表的所有员工的last_name和first_name拼接起来作为Name,中间以一个空格区分CREATE TABLE `employees` ( `emp_no` in ...
- CAN总线(1)--初探(更新中)
前言: CAN总线可以控制可以使用Xilinx中IP核来直接实现,也可以使用专用的CAN芯片(例如:SJA1000)通过单片机和FPGA驱动控制来实现: 目前是使用控制器SJA1000来进行实现: C ...