Codeforces Round #679 (Div. 2, based on Technocup 2021 Elimination Round 1)
考场上只做出来四道,第二天一早就写出来了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)的更多相关文章
- Codeforces Round #692 (Div. 2, based on Technocup 2021 Elimination Round 3) C. Peaceful Rooks (思维,dsu找环)
题意:一个棋盘上有一些"车",现在要让这些"车"跑到左倾斜的对角线上,每次可以移动一个棋子,但是棋盘的任意时刻都不能出现一个"车"能吃另一个 ...
- Codeforces Round #687 (Div. 2, based on Technocup 2021 Elimination Round 2) D. XOR-gun (二进制,异或,前缀和)
题意:给你一组非递减的数,你可以对两个连续的数进行异或,使其合并为一个数,问最少操作多少次使得这组数不满足非递减. 题解:首先,给出的这组数是非递减的,我们考虑二进制,对于三个连续的非递减的最高位相同 ...
- Codeforces Round #687 (Div. 2, based on Technocup 2021 Elimination Round 2) C. Bouncing Ball (后缀和,枚举)
题意:有一长度为\(n\)的平台,平台有的位置有木桩,可以使小球弹起来,小球必须从第\(p\)个位置开始,而且每次都会向右弹\(k\)个单位,然后有的位置是没有木桩的,你可以在这些的空的位置放一个木桩 ...
- Codeforces Round #687 (Div. 2, based on Technocup 2021 Elimination Round 2) B. Repainting Street (枚举)
题意:有\(n\)栋房子,每栋房子都有自己的颜色\(c_i\),你每次可以对连续的长度为\(k\)的区间改变任何房子的颜色,问最少多少次可以使得所有房子颜色相同. 题解:因为只有\(100\)中颜色, ...
- Codeforces Round #687 (Div. 2, based on Technocup 2021 Elimination Round 2) A. Prison Break
题意:有一张\(n\)x\(m\)的图,图中每个点都关押着罪犯,在坐标\((r,c)\)处有一个出口,每名罪犯每秒可以可以像上下最有移动一个单位或者不动,问所有罪犯能够逃离监狱的最少时间. 题解:直接 ...
- Codeforces Round #692 (Div. 2, based on Technocup 2021 Elimination Round 3)
A.In-game Chat 题目:就是从后面数连着的'('的个数是不是严格比剩下的字符多 思路:水题,直接从后往前遍历即可 代码: #include<iostream> #include ...
- Codeforces Round #687 (Div. 2, based on Technocup 2021 Elimination Round 2)
A. Prison Break 题意:就是在一个n*m的矩阵中,以(1,1)为起点(n,m)为终点,每个点以每个单位1s的速度移动,问总共至少需要多少秒,所有的矩阵点就能够全部移动到(r,c)中 思路 ...
- 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++ ...
- 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. 题解:很显然只有 \( ...
随机推荐
- CSS3 新特性总结
1.边框 border-radius: 1-4 length|% / 1-4 length|%; 每个半径的四个值的顺序是:左上角,右上角,右下角,左下角.若省略左下角,和右上角相同,省略右下角,左上 ...
- 关于struts1与struts2
1.Action方面 Action是整个Struts框架的核心内容,Struts1.x与Struts2的Action模型很大的区别.Struts2是一个 pull-MVC架构 ,从开发者角度看,就是说 ...
- 在 Kubernetes 上部署 OpenStack 是什么体验
红蓝出 CP,OpenStack 和 Kubernetes 在一起会怎样? 背景 从去年开始就想深入地学习 Kubernetes,首先想到是在 OpenStack 上能比较轻松地玩转,所以去 尝试了 ...
- Spring中用@DependsOn注解控制Bean的创建顺序
1. 概述 Spirng容器自己会管理bean的生命周期和bean实例化的顺序,但是我们仍然可以根据我们自己的需求进行定制.我可以可以选择使用SmartLifeCycle接口,也可以用@Depends ...
- 039 01 Android 零基础入门 01 Java基础语法 05 Java流程控制之循环结构 01 循环结构概述
039 01 Android 零基础入门 01 Java基础语法 05 Java流程控制之循环结构 01 循环结构概述 本文知识点:循环结构概述 循环结构主要内容 while 循环 do-whiile ...
- Python实现的数据结构与算法之队列详解
本文实例讲述了Python实现的数据结构与算法之队列.分享给大家供大家参考.具体分析如下: 一.概述 队列(Queue)是一种先进先出(FIFO)的线性数据结构,插入操作在队尾(rear)进行,删除操 ...
- Arduino 中 EEprom 写入读取清除
转自:https://www.arduino.cn/thread-1157-1-1.html EEPROM (Electrically Erasable Programmable Read-Only ...
- 温故知新----封装(struct)
上次提到class是最常见的封装,今天发现别人开发的SDK里面有大量的结构体struct 转载: 1. https://blog.csdn.net/a_forever_dream/article/de ...
- GetPrivateProfileString
参考: 1. https://blog.csdn.net/tunnel115/article/details/3081340 2. https://blog.csdn.net/hopedream200 ...
- CF741D Arpa’s letter-marked tree and Mehrdad’s Dokhtar-kosh paths 树上启发式合并(DSU ON TREE)
题目描述 一棵根为\(1\) 的树,每条边上有一个字符(\(a-v\)共\(22\)种). 一条简单路径被称为\(Dokhtar-kosh\)当且仅当路径上的字符经过重新排序后可以变成一个回文串. 求 ...