爆零了,自闭了

小张做项目入职字节

小李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. XJOI 夏令营501-511NOIP训练18 高二学堂

    在美丽的中山纪念中学中,有座高二学堂,同样也是因为一个人,让它们变 成了现在这个样子~那就是我们伟大的级主任.因为他,我们又迎来了一个木有电影,只有对答案的段考日:又迎来了一个不是大礼拜,而是小礼拜的 ...

  2. 【Kata Daily 190919】Sort Out The Men From Boys(排序)

    题目: Scenario Now that the competition gets tough it will Sort out the men from the boys . Men are th ...

  3. 走进C# abstract,了解抽象类与接口的异同

    前言: 最近在研究.NET Core的一些类库源码的时候发现在底层类库中使用了大量的抽象类,然而发现自己搬砖这么多年好像从来没有在项目中使用抽象类或者抽象方法去实现某个功能模块,并且对修饰符Abstr ...

  4. Windows窗口置顶工具 简简单单 - 快快乐乐

    Windows窗口置顶工具 简简单单 - 快快乐乐 JERRY_Z. ~ 2020 / 11 / 12 转载请注明出处!️ 目录 Windows窗口置顶工具 简简单单 - 快快乐乐 一.官网下载Des ...

  5. SpringBoot 构建 Docker 镜像的最佳 3 种方式

    本文将介绍3种技术,通过 Maven 把 SpringBoot 应用构建成 Docker 镜像. (1)使用 spring-boot-maven-plugin 内置的 build-image. (2) ...

  6. 从头学起Verilog(一):组合逻辑基础与回顾

    引言 该部分主要回顾了本科时数字电路中组合逻辑电路部分,内容相对简单和基础. 内容主要包括:布尔代数相关知识,卡诺图,最大项与最小项,竞争和冒险以及一些常见模块 数字电路中的逻辑 组合逻辑:输出可以表 ...

  7. 预估ceph的迁移数据量

    引言 我们在进行 ceph 的 osd 的增加和减少的维护的时候,会碰到迁移数据,但是我们平时会怎么去回答关于迁移数据量的问题,一般来说,都是说很多,或者说根据环境来看,有没有精确的一个说法,到底要迁 ...

  8. 处理Ceph osd的journal的uuid问题

    前言 之前有一篇文章介绍的是,在centos7的jewel下面如果自己做的分区如何处理自动挂载的问题,当时的环境对journal的地方采取的是文件的形式处理的,这样就没有了重启后journal的磁盘偏 ...

  9. android开发导包升级到androidx踩坑记录【转载】

    最近一直在做安卓开发,奈何手中的资料比较老,资料上的一些Import经常没有,十分让人头疼. 感谢简书上的[张晴天天天天天]做的整理. 在这里也记录一下备用. 升级Android Studio后,在 ...

  10. ImportError: No module named 'chardet'

    1.使用requsets出现这个错误,ImportError: No module named 'chardet' 原因:requests依赖其他一些模块 解决:依次使用pip安装即可 pip ins ...