考场上只做出来四道,第二天一早就写出来了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. 把VS Code打造成Java开发IDE

    近期,公司推行正版化,本人使用的是JetBrains教育版,是不允许进行商业开发的,因此开启了艰难的备用IDE选型之路.最终,我选定了轻量级的Visual Studio Code(以下简称VS Cod ...

  2. 手写:javascript中的关键字new

    简单介绍一下new new再熟悉不过了,new后面跟着构造函数,可以创建对象,这个对象的原型指向构造函数的原型对象,说起来可能有点绕,直接看代码吧 function Person(name, age) ...

  3. [GXYCTF2019]禁止套娃 1 &无参数RCE

    [GXYCTF2019]禁止套娃 1 啥都没有那只能上扫描器来一探究竟了. 扫完没有啥结果,但网上找了一下说是git泄露,但是我这里显示了403. <?php include "fla ...

  4. echarts配置进度池

    近日,使用dataV中的配置,完成了进度池图表,但是有有一个缺点,就是官方没有动画方面的配置.如下图: 为了给这个进度池添加动画效果,我反向的在进度池上面铺一层由一格一格与进度池中相同的块状组成的与背 ...

  5. Java学习day03

    day03 课堂笔记 1.数据类型 2.总结第二章到目前为止所学内容: * 标识符 * 关键字 * 字面值 * 变量 成员变量如果没有赋值,系统会自动赋值,而局部变量不手动赋值,则会编译不通过. * ...

  6. Excel双击“单元格”后,自动跳转到相关“工作表

    Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)If Target.Column = ...

  7. C++中头文件简介(stdio.h & chrono)

    参考: 1. https://baike.baidu.com/item/stdio.h 2. https://www.cnblogs.com/jwk000/p/3560086.html 1. stdi ...

  8. Java (二)基于Eclipse配置Commons IO的环境

    上一篇:Java (一)下载APACHE Commons IO 一.新建一个Java Project 二.使用鼠标右键点击工程,选择New > Folder 三.在Folder name输入文件 ...

  9. Java中类型判断的几种方式

    1. 前言 在Java这种强类型语言中类型转换.类型判断是经常遇到的.今天就细数一下Java中类型判断的方法方式. 2. instanceof instanceof是Java的一个运算符,用来判断一个 ...

  10. MeteoInfoLab脚本示例:读取文本文件绘制散度图

    MeteoInfoLab中读取文本文件数据的函数是asciiread,获取文本文件行.列数的函数是numasciirow和numasciicol,和NCL中函数名一致,但都是小写字母.本例中的示例数据 ...