爆零了,自闭了

小张做项目入职字节

小李ak wf入职ms

我比赛爆零月薪3k

我们都有光明的前途

好吧,这场感觉有一点难了,昨天差点卡死在B上,要不受O爷出手相救我就boom zero了

第一题,看上去很唬人,我觉得还得记录变量什么的,1分钟后发现只要查出两个集合的交集大小就行了,连变量增量都不用,拿一血,此时rk 1k6,我人没了

#include <bits/stdc++.h>
using namespace std;
#define limit (315000 + 5)//防止溢出
#define INF 0x3f3f3f3f
#define inf 0x3f3f3f3f3f
#define lowbit(i) i&(-i)//一步两步
#define EPS 1e-6
#define FASTIO ios::sync_with_stdio(false);cin.tie(0);
#define ff(a) printf("%d\n",a );
#define pi(a,b) pair<a,b>
#define rep(i, a, b) for(ll i = a; i <= b ; ++i)
#define per(i, a, b) for(ll i = b ; i >= a ; --i)
#define MOD 998244353
#define traverse(u) for(int i = head[u]; ~i ; i = edge[i].next)
#define FOPEN freopen("C:\\Users\\tiany\\CLionProjects\\acm_01\\data.txt", "rt", stdin)
#define FOUT freopen("C:\\Users\\tiany\\CLionProjects\\acm_01\\dabiao.txt", "wt", stdout)
#define debug(x) cout<<x<<endl
typedef long long ll;
typedef unsigned long long ull;
inline ll read(){
ll sign = 1, x = 0;char s = getchar();
while(s > '9' || s < '0' ){if(s == '-')sign = -1;s = getchar();}
while(s >= '0' && s <= '9'){x = (x << 3) + (x << 1) + s - '0';s = getchar();}
return x * sign;
}//快读
void write(ll x){
if(x < 0) putchar('-'),x = -x;
if(x / 10) write(x / 10);
putchar(x % 10 + '0');
}
int kase;
int n,m,k;
int a[limit];
void solve(){
cin>>n>>m;
set<int>s;
rep(i,1,n){
int x;
cin>>x;
s.insert(x);
}
int tot = 0;
rep(i,1,m){
int x;
cin>>x;
if(s.find(x) != s.end())++tot;
}
cout<<tot<<endl;
}
int main() {
#ifdef LOCAL
FOPEN;
#endif
cin>>kase;
while (kase--){
solve();
}
return 0;
}

B题看上去么得啥思路,后来O神说是记录两边的插值,然后每次记录当前这全都设置成某一位的最小值就行,dbq我现在也没怎么搞懂这个怎么搞,于是滚去看C

#include <bits/stdc++.h>
using namespace std;
#define limit (3150000 + 5)//防止溢出
#define INF 0x3f3f3f3f
#define inf 0x3f3f3f3f3f
#define lowbit(i) i&(-i)//一步两步
#define EPS 1e-6
#define FASTIO ios::sync_with_stdio(false);cin.tie(0);
#define ff(a) printf("%d\n",a );
#define pi(a,b) pair<a,b>
#define rep(i, a, b) for(ll i = a; i <= b ; ++i)
#define per(i, a, b) for(ll i = b ; i >= a ; --i)
#define MOD 998244353
#define traverse(u) for(int i = head[u]; ~i ; i = edge[i].next)
#define FOPEN freopen("C:\\Users\\tiany\\CLionProjects\\acm_01\\data.txt", "rt", stdin)
#define FOUT freopen("C:\\Users\\tiany\\CLionProjects\\acm_01\\dabiao.txt", "wt", stdout)
#define debug(x) cout<<x<<endl
typedef long long ll;
typedef unsigned long long ull;
inline ll read(){
ll sign = 1, x = 0;char s = getchar();
while(s > '9' || s < '0' ){if(s == '-')sign = -1;s = getchar();}
while(s >= '0' && s <= '9'){x = (x << 3) + (x << 1) + s - '0';s = getchar();}
return x * sign;
}//快读
void write(ll x){
if(x < 0) putchar('-'),x = -x;
if(x / 10) write(x / 10);
putchar(x % 10 + '0');
}
int kase;
int n,m,k;
ll a[limit];
ll dp2[limit],dp[limit];
void solve(){
cin>>n;
ll tot = 0,ans = 0x3f3f3f3f3f3f3f;
rep(i,1,n){
cin>>a[i];
dp[i] = 0;
dp2[i] = 0;
}
dp2[1] = max(dp2[1],llabs(a[2] - a[1]));
rep(i,2,n){
ll tmp = llabs(a[i] - a[i - 1]);
tot += tmp;
dp[i] = tmp;
}
rep(i,1,n){
if(i == 1){
ans = min(ans , tot - dp[2]);
}else if(i == n){
ans = min(ans,tot - dp[n]);
}
else if((a[i] <= a[i + 1] && a[i] <= a[i - 1])){
ans = min(ans,tot + abs(a[i - 1] - a[i + 1]) - dp[i + 1 ] - dp[i]);
}else if(a[i] >= a[i + 1] && a[i] >= a[i - 1]){
ans = min(ans,tot + abs(a[i + 1] - a[i - 1]) - dp[i + 1] - dp[i]);
}
}
cout<<ans<<endl;
}
int main() {
#ifdef LOCAL
FOPEN;
#endif
cin>>kase;
while (kase--){
solve();
}
return 0;
}

C题一看就很阅读理解,先是花半个小时看题,之后大概清楚了什么意思,大概是一个0-9构成的棋盘,每次找最大的又i(i = 0 - 9)三角形构成的平行四边形面积,其中一边必须平行于坐标轴,每次可以在棋盘上改变不超过一个不影响后续的元素,求以0-9各个为顶点的最大面积

首先显然想到,三角形面积 = 底 X 高 / 2,不用/2了,好耶。大概思路就是预处理一下左右,上下两个维度的第一个元素每一行或者每一列最靠边缘的元素位置,然后枚举看每一行,对于0-9,存在以下几种对答案产生贡献的情况

1. 这行有至少两个数字i,以最边上两个元素为底寻找一个与其垂直的维度的点,或者1,n这两个端点,构成的三角形比原先大

2. 这行存在一个数字,但用次行/列第一个或者最后一个元素改变为顶点数字作为底,构成的三角形比原先大

3. 这行的情况与1相同,不添加任何数字,不做改动,构成的三角形就比原先大

然后我赛场写了100+行大模拟,好在过了,写完一身冷汗,代码如下:

#include <bits/stdc++.h>
using namespace std;
#define limit (3150000 + 5)//防止溢出
#define INF 0x3f3f3f3f
#define inf 0x3f3f3f3f3f
#define lowbit(i) i&(-i)//一步两步
#define EPS 1e-6
#define FASTIO ios::sync_with_stdio(false);cin.tie(0);
#define ff(a) printf("%d\n",a );
#define pi(a,b) pair<a,b>
#define rep(i, a, b) for(ll i = a; i <= b ; ++i)
#define per(i, a, b) for(ll i = b ; i >= a ; --i)
#define MOD 998244353
#define traverse(u) for(int i = head[u]; ~i ; i = edge[i].next)
#define FOPEN freopen("C:\\Users\\tiany\\CLionProjects\\acm_01\\data.txt", "rt", stdin)
#define FOUT freopen("C:\\Users\\tiany\\CLionProjects\\acm_01\\dabiao.txt", "wt", stdout)
#define debug(x) cout<<x<<endl
typedef long long ll;
typedef unsigned long long ull;
inline ll read(){
ll sign = 1, x = 0;char s = getchar();
while(s > '9' || s < '0' ){if(s == '-')sign = -1;s = getchar();}
while(s >= '0' && s <= '9'){x = (x << 3) + (x << 1) + s - '0';s = getchar();}
return x * sign;
}//快读
void write(ll x){
if(x < 0) putchar('-'),x = -x;
if(x / 10) write(x / 10);
putchar(x % 10 + '0');
}
int kase;
int n,m,k;
ll a[limit];
ll dp2[limit],dp[limit];
void solve(){
cin>>n;
ll tot = 0,ans = 0x3f3f3f3f3f3f3f;
rep(i,1,n){
cin>>a[i];
dp[i] = 0;
dp2[i] = 0;
}
dp2[1] = max(dp2[1],llabs(a[2] - a[1]));
rep(i,2,n){
ll tmp = llabs(a[i] - a[i - 1]);
tot += tmp;
dp[i] = tmp;
}
rep(i,1,n){
if(i == 1){
ans = min(ans , tot - dp[2]);
}else if(i == n){
ans = min(ans,tot - dp[n]);
}
else if((a[i] <= a[i + 1] && a[i] <= a[i - 1])){
ans = min(ans,tot + abs(a[i - 1] - a[i + 1]) - dp[i + 1 ] - dp[i]);
}else if(a[i] >= a[i + 1] && a[i] >= a[i - 1]){
ans = min(ans,tot + abs(a[i + 1] - a[i - 1]) - dp[i + 1] - dp[i]);
}
}
cout<<ans<<endl;
}
int main() {
#ifdef LOCAL
FOPEN;
#endif
cin>>kase;
while (kase--){
solve();
}
return 0;
}

D题没时间搞了,但后来和Dxtst老哥讨论了下似乎是当前位上0或1,如果是1对于答案的贡献为2^k, 其他结论今晚再搞

奥里给!

cf div2 round 688 题解的更多相关文章

  1. [题解向] CF#Global Round 1の题解(A $\to$ G)

    这里是总链接\(Link\). \(A\) 题意:求\(\sum_{i=1}^{k} a_i\times b^{k-i}\)的奇偶性, \(k = \Theta(n \log n)\) --其实很容易 ...

  2. CF Global Round 21 题解 (CDEG)

    C 把 \(a,b\) 全拆开然后比较即可(因为分裂和合并是互逆的) 注意开 long long . using namespace std; typedef long long ll; typede ...

  3. CF Educational Round 78 (Div2)题解报告A~E

    CF Educational Round 78 (Div2)题解报告A~E A:Two Rival Students​ 依题意模拟即可 #include<bits/stdc++.h> us ...

  4. CFEducational Codeforces Round 66题解报告

    CFEducational Codeforces Round 66题解报告 感觉丧失了唯一一次能在CF上超过wqy的机会QAQ A 不管 B 不能直接累计乘法打\(tag\),要直接跳 C 考虑二分第 ...

  5. Codeforces Round #556 题解

    Codeforces Round #556 题解 Div.2 A Stock Arbitraging 傻逼题 Div.2 B Tiling Challenge 傻逼题 Div.1 A Prefix S ...

  6. LibreOJ β Round #2 题解

    LibreOJ β Round #2 题解 模拟只会猜题意 题目: 给定一个长为 \(n\) 的序列,有 \(m\) 次询问,每次问所有长度大于 \(x\) 的区间的元素和的最大值. \(1 \leq ...

  7. Codeforces Round #569 题解

    Codeforces Round #569 题解 CF1179A Valeriy and Deque 有一个双端队列,每次取队首两个值,将较小值移动到队尾,较大值位置不变.多组询问求第\(m\)次操作 ...

  8. Codeforces Round #557 题解【更完了】

    Codeforces Round #557 题解 掉分快乐 CF1161A Hide and Seek Alice和Bob在玩捉♂迷♂藏,有\(n\)个格子,Bob会检查\(k\)次,第\(i\)次检 ...

  9. CF Edu Round 71

    CF Edu Round 71 A There Are Two Types Of Burgers 贪心随便模拟一下 #include<iostream> #include<algor ...

随机推荐

  1. Flink的DataSource三部曲之三:自定义

    欢迎访问我的GitHub https://github.com/zq2599/blog_demos 内容:所有原创文章分类汇总及配套源码,涉及Java.Docker.Kubernetes.DevOPS ...

  2. 中科图新成为Bentley产品培训合作伙伴!质量服务双升级

    中科图新从2016年起开办ContextCapture产品培训,目前已累计培训了500多家企事业单位,涉及传统测绘单位.无人机航测.规划设计.建筑工程.水利.电力.交通.文保等十多个行业.实力过硬,口 ...

  3. project--客户信息管理系统

    软件设计分析 该软件有三个模块组成:Customer  CustomerList  CustomerView Customer 为实体对象,用来封装客户信息: CustomerList 为 Custo ...

  4. SPI的学习和ESP8266的SPI通讯测试

    SPI简介: SPI是串行外设接口(Serial Peripheral Interface)的缩写.SPI,是一种高速的,全双工,同步的通信总线,并且在芯片的管脚上只占用四根线,节约了芯片的管脚,同时 ...

  5. Boltzmann Machine 玻尔兹曼机入门

    Generative Models 生成模型帮助我们生成新的item,而不只是存储和提取之前的item.Boltzmann Machine就是Generative Models的一种. Boltzma ...

  6. Future Callable 线程池 例1

    package com.niewj.concurrent; import java.util.concurrent.Callable; import java.util.concurrent.Exec ...

  7. CV 履历 格式

    CV 指的是 "Curriculum Vitae" Curriculum vitae 在拉丁语中的意思是"生命的故事" CV 经常被称为 "Resum ...

  8. quic 分析 1

    问题1:quic握手过程是怎样的? 怎样节约握手时间?握手时间多少个RTT?握手过程成涉及到哪些概念以及变量(代码) 0~1 RTT握手过程   QUIC握手的过程是需要一次数据交互,0-RTT时延即 ...

  9. yum 的一些问题总结

    1. yum 只删除目标,不删除依赖 rpm -e --nodeps xxx 2.yum remove 出错 报错 Error: Cannot retrieve repository metadata ...

  10. Vue 计算属性与方法

    computed 基本使用 如果数据需要有复杂的计算,则可以在Vue实例中定义计算属性,再交由mustache进行渲染. computed内部其实是通过getttr实现的,所以不用加括号即可完成其下方 ...