考场上只做出来四道,第二天一早就写出来了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. OpenGL渲染时的数据流动

    OpenGL渲染时的数据流动 文件地址:https://wws.lanzous.com/i2aR3gu251e 链接失效记得回复哦!马上更新!

  2. SQL Server 2008 R2执行存储过程sp_MailItemResultSets引起大量PREEMPTIVE_OS_WAITFORSINGLEOBJEC等待

      从监控工具DPA中发现一个数据库(SQL Server 2008 R2)的等待事件突然彪增,下钻分析发现数据库执行存储过程sp_MailItemResultSets时,引起了非常严重的等待(Hig ...

  3. Linux系统编程—条件变量

    条件变量是用来等待线程而不是上锁的,条件变量通常和互斥锁一起使用.条件变量之所以要和互斥锁一起使用,主要是因为互斥锁的一个明显的特点就是它只有两种状态:锁定和非锁定,而条件变量可以通过允许线程阻塞和等 ...

  4. Word云(标签云)生成器控件。net Windows。形式在c#中

    下载demo - 37.1 KB 下载source code - 48.7 KB 背景 这种控制方式的灵感来自于一种名为Wordle的基于网络的免费单词云生成器.实际上,这个控件是我的项目http:/ ...

  5. iptables 和firewalld 区别

    在RHEL7里有几种防火墙共存:firewalld.iptables.ebtables,默认是使用firewalld来管理netfilter子系统,不过底层调用的命令仍然是iptables等. fir ...

  6. 热力图 vue 项目中使用热力图插件 “heatmap.js”(保姆式教程)

    我现在写的这项目是用CDN引入 heatmap.js, 可根据自己项目情况使用哪种方式引入插件. 官网地址 "https://www.patrick-wied.at/static/heatm ...

  7. 关于android和Linux的一些问题

    1.Android为什么选择java? 由于java虚拟机,实现软件层的编程与硬件无关性(无需进行特定编译或平台配置). 2.Android和Linux内核区别? Android上的应用软件运行在da ...

  8. Request对象基础应用实例代码一

    输入用户名:<br><input type="text" name="yhm"><br><br>输入密码:< ...

  9. day50 Pyhton 前端01

    文档结构: <!-- 定义文档类型 --> <!DOCTYPE html> <!-- 文档 --> <html lang='en'> <!-- 仅 ...

  10. day47 Pyhton 数据库Mysql 04

    # 表结构 # 建表 - 表的增加 # create table # 删表 - 表的删除 # drop table # 改表 - 表的修改 # alter table 表名 # rename 新表名 ...