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)的更多相关文章

  1. 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 ...

  2. Codeforces Round #366 Div.2[11110]

    这次出的题貌似有点难啊,Div.1的Standing是这样的,可以看到这位全站排名前10的W4大神也只过了AB两道题. A:http://codeforces.com/contest/705/prob ...

  3. 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 ...

  4. 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 ...

  5. Codeforces Round #366 (Div. 2) B 猜

    B. Spider Man time limit per test 2 seconds memory limit per test 256 megabytes input standard input ...

  6. Codeforces Round #366 (Div. 2) A

    A. Hulk time limit per test 1 second memory limit per test 256 megabytes input standard input output ...

  7. 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 ...

  8. 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 ...

  9. 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 ...

随机推荐

  1. MRC迁移ARC之__block

    今日帮着同事把老项目从MRC迁移至ARC,大部分工作无非是删除release,[super dealloc]等方法,只要关闭了MRC编译选项后,编译器能自动帮你检查,block就有一些不一样了,发现许 ...

  2. GSM07.10协议中串口复用的注意事项

    DLCI:0通道(地址域中DLCI==0)是控制通道,用来传输管理信息.逻辑通道的建立和关闭,睡眠模式的启动和唤醒,流量控制等控制信息都是用该通道. DLCI:1~n通道是逻辑通道,用来传输用户数据. ...

  3. JQuery EasyUI DataGrid根据条件设置表格行样式(背景色)

    1.javascript定义函数返回样式 <script type="text/javascript"> //根据条件设置表格行背景颜色 function setRow ...

  4. Linux学习之十--.Net Core环境搭建以及Nginx的搭建

    一.Centos7下.Net Core 环境安装: 链接:https://www.microsoft.com/net/core#linuxcentos 按照步骤来: yum install libun ...

  5. Android控制ScrollView滚动

    有两种办法,第一种,使用scrollTo(),这个方法不需要handler,直接调用就行 第二种方式,使用fullScrol() 下面我们看一下这个函数: scrollView.fullScroll( ...

  6. 跟着百度学PHP[5]函数篇2-PHP中的特殊形式的函数

    目录...................................................... .00x1 可变函数 在PHP里面如果说将“函数名称”赋予字符串类型的变量.在调用这个 ...

  7. Windows下C编程获取软件安装列表信息

    代码如下: #include <windows.h> #include <stdio.h> #include <iostream> #include <vec ...

  8. 【Network】修改docker启动默认网桥docker0为自定义网桥

    自定义网桥 除了默认的 docker0 网桥,用户也可以指定网桥来连接各个容器. 在启动 Docker 服务的时候,使用 -b BRIDGE或--bridge=BRIDGE 来指定使用的网桥. 如果服 ...

  9. iOS9 中的On-Demand Resources,编辑中。。。

    最近要写一个包含许多Html内容的应用,就想能不能通过ios9的这个新特性,缩小一下app的体积,也看看这个新特性和最常使用的用服务器下载资源包有什么不同. 先看官方文档: http://www.co ...

  10. mysql基准测试

    1. 及注册时有两种主要的策略:①正对整个系统的整体测试(集成式full-stack) ②单独测试mysql(但组件式基准测试single-component) 2.获取系统性能和状态(需要记录的数据 ...