考场上只做出来四道,第二天一早就写出来了E,蛮绝望的。

A Finding Sasuke

水构造

#include <cstdio>
#include <algorithm>
typedef long long ll;
int T,n;
int a[110]; template <typename T>
inline void read(T &x){
x = 0; char ch = getchar(); int f = 1;
for(;ch < '0' || ch > '9'; ch = getchar()) if(ch == '-') f = -1;
for(;ch >= '0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
x *= f;
}
int main(){
read(T);
while(T--){
read(n);
for(int i = 1;i <= n; i++) read(a[i]);
for(int i = 2;i <= n; i += 2)
printf("%d %d ",-a[i],a[i - 1]);
printf("\n");
}
return 0;
}

B A New Technique

#include <cstdio>
#include <algorithm>
#include <vector>
#include <map>
typedef long long ll;
const int M = 510;
int T,n,m;
int a[M][M]; template <typename T>
inline void read(T &x){
x = 0; char ch = getchar(); int f = 1;
for(;ch < '0' || ch > '9'; ch = getchar()) if(ch == '-') f = -1;
for(;ch >= '0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
x *= f;
}
std::map <int,int> mp;
int main(){
read(T);
while(T--){
mp.clear();
read(n); read(m);
for(int i = 1;i <= n; i++)
for(int j = 1;j <= m; j++){
read(a[i][j]);
if(j == 1) mp[a[i][j]] = i;
}
for(int i = 1,tmp;i <= m; i++)
for(int j = 1;j <= n; j++){
read(tmp);
if(mp[tmp] != 0){
for(int k = 1;k <= m; k++)
printf("%d ",a[mp[tmp]][k]);
printf("\n");
}
}
}
return 0;
}

C Perform Easily

思维题

#include <cstdio>
#include <algorithm>
#include <vector>
const int M = 100010, inf = 0x3f3f3f3f;
int a[7], n;
int b[M];
int ans = inf;
int maxx; std::vector<std::pair<int, std::pair<int, int> > > v;
template <typename T>
inline void read(T &x){
x = 0; char ch = getchar(); int f = 1;
for(;ch < '0' || ch > '9'; ch = getchar()) if(ch == '-') f = -1;
for(;ch >= '0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
x *= f;
}
inline bool cmp(int x,int y){
return x > y;
}
int main(){
for(int i = 1;i <= 6; i++) read(a[i]);
read(n);
for(int i = 1;i <= n; i++) read(b[i]);
std::sort(a + 1,a + 1 + 6,cmp);
for(int i = 1;i <= n; i++){
for(int j = 1; j <= 6; j++) v.push_back(std::make_pair(b[i] - a[j],std::make_pair(i, j)));
maxx = std::max(maxx,b[i] - a[1]);
}
std::sort(v.begin(),v.end());
bool flag;
for(int i = 0,l,r;i < int(v.size()); ){
l = i; r = i;
while(r < int(v.size()) - 1 && v[r + 1].first == v[r].first) r++;
flag = 0;
ans = std::min(ans,maxx - v[i].first);
for(int j = l; j <= r; j++){
if(v[j].second.second == 6){
flag = 1; break;
}
maxx = std::max(maxx,b[v[j].second.first] - a[v[j].second.second + 1]);
}
if(flag) break;
i = r + 1;
}
printf("%d\n",ans);
return 0;
}

D Shurikens

大模拟

#include <cstdio>
#include <algorithm>
const int M = 1e5 + 19;
int n; namespace tr{
int tr[M];
void update(int x, int k){
for(; x <= n; x += x & -x)
tr[x] = std::max(tr[x], k);
}
int query(int x){
int res = 0;
for(; x; x -= x & -x)
res = std::max(res, tr[x]);
return res;
}
}//树状数组
int b[M], f[M];
int find(int node){
return node == f[node] ? node : f[node] = find(f[node]);
}
template <typename T>
inline void read(T &x){
x = 0; char ch = getchar(); int f = 1;
for(;ch < '0' || ch > '9'; ch = getchar()) if(ch == '-') f = -1;
for(;ch >= '0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
x *= f;
}
int cnt = 0, x;
int main(){
read(n);
for(int i = 1; i <= n + 1; ++i) f[i] = i;
for(int i = 1; i <= 2 * n; ++i){
char ch = getchar();
while(ch != '+' && ch != '-') ch = getchar();
if(ch == '+') ++cnt;
else{
read(x);
int pos = find(tr::query(n - x + 1) + 1);
if(pos <= cnt) b[pos] = x, tr::update(n - x + 1, cnt), f[find(pos)] = find(pos + 1);
else return printf("NO\n"), 0;
}
}
printf("YES\n");
for(int i = 1; i <= n; i++) printf("%d ", b[i]);
return 0;
}

E Solo mid Oracle

有一个显而易见的结论: 造成a伤害之后,如果怪回了超过a的血量,那么这次就算白打了。

因此只需要在回满血之前尽可能地输出,就一定是最优的。

具体见代码。

#include <cstdio>
#include <algorithm>
typedef long long ll;
int T,a,b,c,d; template <typename T>
inline void read(T &x){
x = 0; char ch = getchar(); int f = 1;
for(;ch < '0' || ch > '9'; ch = getchar()) if(ch == '-') f = -1;
for(;ch >= '0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
x *= f;
}
int main(){
read(T);
while(T--){
read(a); read(b); read(c); read(d);
if(a > 1ll * b * c){
printf("-1\n"); continue;
}
if(d >= c){
printf("%d\n",a); continue;
}
int k = a / (1ll * b * d);
printf("%lld\n",(1ll * a * (k + 1) - 1ll * k * (k + 1) * b * d / 2));
}
return 0;
}

Codeforces Round #679 (Div. 2, based on Technocup 2021 Elimination Round 1)的更多相关文章

  1. Codeforces Round #692 (Div. 2, based on Technocup 2021 Elimination Round 3) C. Peaceful Rooks (思维,dsu找环)

    题意:一个棋盘上有一些"车",现在要让这些"车"跑到左倾斜的对角线上,每次可以移动一个棋子,但是棋盘的任意时刻都不能出现一个"车"能吃另一个 ...

  2. Codeforces Round #687 (Div. 2, based on Technocup 2021 Elimination Round 2) D. XOR-gun (二进制,异或,前缀和)

    题意:给你一组非递减的数,你可以对两个连续的数进行异或,使其合并为一个数,问最少操作多少次使得这组数不满足非递减. 题解:首先,给出的这组数是非递减的,我们考虑二进制,对于三个连续的非递减的最高位相同 ...

  3. Codeforces Round #687 (Div. 2, based on Technocup 2021 Elimination Round 2) C. Bouncing Ball (后缀和,枚举)

    题意:有一长度为\(n\)的平台,平台有的位置有木桩,可以使小球弹起来,小球必须从第\(p\)个位置开始,而且每次都会向右弹\(k\)个单位,然后有的位置是没有木桩的,你可以在这些的空的位置放一个木桩 ...

  4. Codeforces Round #687 (Div. 2, based on Technocup 2021 Elimination Round 2) B. Repainting Street (枚举)

    题意:有\(n\)栋房子,每栋房子都有自己的颜色\(c_i\),你每次可以对连续的长度为\(k\)的区间改变任何房子的颜色,问最少多少次可以使得所有房子颜色相同. 题解:因为只有\(100\)中颜色, ...

  5. Codeforces Round #687 (Div. 2, based on Technocup 2021 Elimination Round 2) A. Prison Break

    题意:有一张\(n\)x\(m\)的图,图中每个点都关押着罪犯,在坐标\((r,c)\)处有一个出口,每名罪犯每秒可以可以像上下最有移动一个单位或者不动,问所有罪犯能够逃离监狱的最少时间. 题解:直接 ...

  6. Codeforces Round #692 (Div. 2, based on Technocup 2021 Elimination Round 3)

    A.In-game Chat 题目:就是从后面数连着的'('的个数是不是严格比剩下的字符多 思路:水题,直接从后往前遍历即可 代码: #include<iostream> #include ...

  7. Codeforces Round #687 (Div. 2, based on Technocup 2021 Elimination Round 2)

    A. Prison Break 题意:就是在一个n*m的矩阵中,以(1,1)为起点(n,m)为终点,每个点以每个单位1s的速度移动,问总共至少需要多少秒,所有的矩阵点就能够全部移动到(r,c)中 思路 ...

  8. Codeforces Round #517 (Div. 2, based on Technocup 2019 Elimination Round 2)

    Codeforces Round #517 (Div. 2, based on Technocup 2019 Elimination Round 2) #include <bits/stdc++ ...

  9. Codeforces Round #596 (Div. 2, based on Technocup 2020 Elimination Round 2)

    A - Forgetting Things 题意:给 \(a,b\) 两个数字的开头数字(1~9),求使得等式 \(a=b-1\) 成立的一组 \(a,b\) ,无解输出-1. 题解:很显然只有 \( ...

随机推荐

  1. Combine 框架,从0到1 —— 5.Combine 中的 Subjects

    本文首发于 Ficow Shen's Blog,原文地址: Combine 框架,从0到1 -- 5.Combine 中的 Subjects. 内容概览 前言 PassthroughSubject C ...

  2. Linux等待队列(Wait Queue)

    1. Linux等待队列概述 Linux内核的等待队列(Wait Queue)是重要的数据结构,与进程调度机制紧密相关联,可以用来同步对系统资源的访问.异步事件通知.跨进程通信等.在Linux中,等待 ...

  3. Android 字符串的常用操作

    目录 Substring 基本语法 IndexOf 基本语法 Split 基本语法 Substring 基本语法 str.substring(","); //从第一个,号开始截取 ...

  4. Apache CXF基本使用

    一.服务端开发 1.创建web项目 2.导入jar包 3.web.xml中配置Servlet 1 <!-- 配置CXF框架提供的Servlet --> 2 <servlet> ...

  5. 拉格朗日乘子法 Lagrange multipliers

  6. MCU(Micro Control Unit)中文名称为微控制单元

    参考:http://www.elecfans.com/dianzichangshi/mcu.html 什么是mcu_mcu是什么意思 标签:MCU(471)单片机(3098)微控制器(503) MCU ...

  7. Django ORM 引发的数据库 N+1 性能问题

    背景描述 最近在使用 Django 时,发现当调用 api 后,在数据库同一个进程下的事务中,出现了大量的数据库查询语句.调查后发现,是由于 Django ORM 的机制所引起. Django Obj ...

  8. Angular8 ie兼容性解决

    启用腻子脚本 polyfills.ts /* IE9, IE10 and IE11 requires all of the following polyfills. */ import 'core-j ...

  9. es使用--新建、删除、增删改数据

    # 进入bin目录 cd /czz/elsearch/bin # 后台启动(不加-d参数则是前台启动,日志在控制台) # 后台启动日志如果不配置,在es目录的logs下面 ./elasticsearc ...

  10. day63 Pyhton 框架Django 06

    内容回顾 1.装饰器 装饰器:是一个闭包函数,在不改变原函数的代码和调用方式的基础上,给原函数增加功能. def wrapper(func): def inner(*args,**kwargs): # ...