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. nginx tomcat session丢失的问题

    nginx反向代理tomcat,出现seesion获取不到的问题. 网上搜索到的解决方案大多是集群tomcat共享session共享的问题,但我这个只有一台tomcat服务器,不涉及到服务器集群问题. ...

  2. node.js下使用RSA加密事例(windows)

    1.安装openss 直接下载window下的安装包 http://houjixin.blog.163.com/blog/static/3562841020144143494875/ 以我发博文现在的 ...

  3. IOS与Android APP界面设计规范要点

    IOS篇 一.尺寸及分辨率 iPhone界面尺寸:320*480.640*960.640*1136 iPhone6:4.7英寸(1334×750),iPhone6 Plus:5.5英寸(1920×10 ...

  4. jquery_DOM笔记4

    jQuery遍历函数: add()添加,可以是样式,字符串,元素,文本,js对象 andself() 指向匹配元素本身 chilidren() 匹配元素的所有子元素的匹配元素 closest() 从本 ...

  5. No.25

    每天三件事必做: 1.背单词: 2.跑步: 3.读书.

  6. 使用visual studio 调试android 程序 ,真机调试

    1 使用visual studio 2015 新建 blank android APP , 2 安卓手机调整到开发者模式 3 通过USB链接到PC 4 自动检测 设备(这一步貌似没有立即检测到真机设备 ...

  7. Ternary Expression Parser

    Given a string representing arbitrarily nested ternary expressions, calculate the result of the expr ...

  8. 报错:1130-host ... is not allowed to connect to this MySql server

    报错:1130-host ... is not allowed to connect to this MySql server   解决方法: 1. 改表法. 可能是你的帐号不允许从远程登陆,只能在l ...

  9. 448. Find All Numbers Disappeared in an Array

    https://leetcode.com/problems/find-all-numbers-disappeared-in-an-array/ 给出一列数,1 ≤ a[i] ≤ n,n是数组大小,有些 ...

  10. Redis的入门及注意事项

    1.redis简介 Remote Dictionary Server Redis 与其他 key - value 缓存产品有以下三个特点: Redis支持数据的持久化,可以将内存中的数据保存在磁盘中, ...