Codeforces Round #366 (Div. 2)
CF 复仇者联盟场。。。
水题 A - Hulk(绿巨人)
输出love hate。。。
#include <bits/stdc++.h> typedef long long ll;
const int N = 1e5 + 5; int main() {
int n;
scanf ("%d", &n);
printf ("I hate");
for (int i=1; i<n; ++i) {
if (i & 1) printf (" that I love");
else printf (" that I hate");
}
puts (" it");
return 0;
}
博弈+打表找规律 B - Spider Man(蜘蛛侠)
注意到每次多一个圈,之前的还是初始状态,各组是独立的,所以打个表或者分析一下就能找到规律。
#include <bits/stdc++.h> typedef long long ll;
const int N = 1e5 + 5;
int a[N];
int sg[105]; int SG(int x) {
if (x < 2) return sg[x] = 0;
bool vis[105];
memset (vis, false, sizeof (vis));
for (int i=1; i<x; ++i) {
vis[SG (i) ^ (SG (x-i))] = true;
}
int &ret = sg[x] = 0;
while (vis[ret]) ret++;
return ret;
} void test() {
memset (sg, -1, sizeof (sg));
for (int i=1; i<=20; ++i) {
printf ("sg[%d]=%d\n", i, SG (i));
}
} int main() {
//test ();
int n;
scanf ("%d", &n);
for (int i=1; i<=n; ++i) scanf ("%d", a+i);
int ans = 0;
for (int i=1; i<=n; ++i) {
int res = a[i] & 1 ? 0 : 1;
ans ^= res;
printf ("%d\n", ans ? 1 : 2);
}
return 0;
}
构造 C - Thor(雷神)
题意:一个手机有n个应用,有三种操作:
1. 第x个应用有一个未读信息;
2. 读完当前第x个应用的所有未读信息;
3. 读完最前面t个信息(信息可能被重读);
每次操作后输出当前未读信息的条数。
思路:第3个操作“最前面t个”很关键,那么只要进行max(t) 次操作。如果要读的信息在之后时间点被读掉(第2种操作)那就不更新,那么维护下最新的“清空”的应用编号和时间即可。之前有个地方写了continue,结果答案没输出,WA了好久。
#include <bits/stdc++.h> typedef long long ll;
const int N = 3e5 + 5; int cnt[N];
int clear_time[N];
std::pair<int, int> que[N]; int main() {
int n, q;
scanf ("%d%d", &n, &q);
int m = 0, ans = 0;
int tp, x, t, maxt = 0;
for (int i=1; i<=q; ++i) {
scanf ("%d", &tp);
if (tp == 1 || tp == 2) {
scanf ("%d", &x);
if (tp == 1) {
cnt[x]++;
ans++;
que[++m] = {x, i};
} else {
ans -= cnt[x];
cnt[x] = 0;
clear_time[x] = i;
}
} else {
scanf ("%d", &t);
if (t > maxt) {
for (int j=maxt+1; j<=t; ++j) {
int pos = que[j].first, tim = que[j].second;
if (clear_time[pos] >= tim) continue;
cnt[pos]--;
ans--;
}
maxt = t;
}
}
printf ("%d\n", ans);
}
return 0;
}
Codeforces Round #366 (Div. 2)的更多相关文章
- 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 ...
- 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 ...
- Codeforces Round #366 (Div. 2) C Thor(模拟+2种stl)
Thor 题意: 第一行n和q,n表示某手机有n个app,q表示下面有q个操作. 操作类型1:app x增加一条未读信息. 操作类型2:一次把app x的未读信息全部读完. 操作类型3:按照操作类型1 ...
- Codeforces Round #366 (Div. 2)_B. Spider Man
B. Spider Man time limit per test 2 seconds memory limit per test 256 megabytes input standard input ...
- Codeforces Round #366 (Div. 2)_C. Thor
C. Thor time limit per test 2 seconds memory limit per test 256 megabytes input standard input outpu ...
随机推荐
- 模板化的七种排序算法,适用于T* vector<T>以及list<T>
最近在写一些数据结构以及算法相关的代码,比如常用排序算法以及具有启发能力的智能算法.为了能够让写下的代码下次还能够被复用,直接将代码编写成类模板成员函数的方式,之所以没有将这种方式改成更方便的函数模板 ...
- vim 常用命令逐渐熟悉以及常用的配置记录
本篇博客记录的是我自己学习vim的常用命令的过程中,各个命令的逐渐熟悉的顺序(有一部分已经熟悉的命令没有列出),已经对vim编辑器本身的一些设置的记录 1.G 快速将光标切换到文件的最底部 2.u 撤 ...
- FTP下载文件失败
这几天的定时任务下载文件的脚本失败了. 于是手工执行测试,发现报550 Permission denied. Passive mode refused. 意思就是被动模式下,没有权限获取文件. 解决方 ...
- 关于JQ toggle 的注意事项
1.9.1以后的版本,好像不支持 jq 的 toggle function的用法啦.
- jquery.nicescroll.js可全屏可改滚动条颜色的滚动条插件-推荐
有一款很棒的插件 http://www.ijquery.cn/?p=666
- Windows无线网“无法连接到这个网络”的解决办法
最近我的笔记本(Win10系统)连接无线网时总是出现"无法连接到这个网络"的错误.为此折腾了一天,通过各种百度,终于找到了适合我的解决办法,在此记录一下. 问题描述 最近因为宿舍的 ...
- ng-disabled 不起作用的解决办法
不知道这算不算 Angular.js 的一个bug.但搜索一番后找到了一个变通的解决办法. 业务需求是这样的, 按钮被点击一次之后就设置为禁用状态, 以阻止多次无效的点击.但现在很多框架都用 < ...
- Ruby中实现module继承
module FooModule def self.included base base.extend ClassMethods end module ClassMethods def ...
- 爬虫 htmlUnit遇到Cannot locate declared field class org.apache.http.impl.client.HttpClientBuilder.dnsResolve错误
当在使用htmlUnit时遇到无法定位org.apache.http.impl.client.HttpClientBuilder.dnsResolver类时,此时所需要的依赖包为: <depen ...
- java+eclipse+selenium环境搭建
这几天在学selenium,大头虾的我.安装环境还是遇到了挺多问题,赶紧来记录下.不然下次又...(参考虫师的<Selenium2 Java自动化测试实战>),就随便写写加深下自己的印象. ...