爆零了,自闭了

小张做项目入职字节

小李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. Luogu P2024 [NOI2001]食物链

    并查集 首先先要读懂题目,a是b的食物的话,b的天敌是a,b的食物是a的天敌 比如,人吃鸡,鸡吃草,那么草吃人..... 所以建3个并查集,+n时表示这是其食物,+2*n时表示这是其天敌 所以当x,y ...

  2. bash中选择结构、循环结构与break、continue

    if两种选择结构 if 测试条件; then 程序块 else 程序块 fi if 测试条件1; then 程序块 elif 测试条件2; then 程序块 ... elif 程序条件n; then ...

  3. 基于synchronized锁的深度解析

    1. 问题引入 小伙伴们都接触过线程,也都会使用线程,今天我们要讲的是线程安全相关的内容,在这之前我们先来看一个简单的代码案例. 代码案例: /** * @url: i-code.online * @ ...

  4. 15 CGI和WSGI

    15 CGI和WSGI CGI是通用网关接口,是连接web服务器和应用程序的接口,用户通过CGI来获取动态数据或文件等. CGI程序是一个独立的程序,它可以用几乎所有语言来写,包括perl,c,lua ...

  5. char和signed char不同编译器下的使用反思

    遇到一个问题,在使用一个算法的时候出现了仿真正常,但是在使用时出现函数的返回数据只有正值的异常. 在定位算法问题的时候,由算法函数最后的返回值由后向前推,最后发现问题在与char类型的值在不同编译器下 ...

  6. [python学习手册-笔记]002.python核心数据类型

    python核心数据类型 ❝ 本系列文章是我个人学习<python学习手册(第五版)>的学习笔记,其中大部分内容为该书的总结和个人理解,小部分内容为相关知识点的扩展. 非商业用途转载请注明 ...

  7. php post请求https

    <?php $url = 'https://www.xxx.com'; $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $url); c ...

  8. [MIT6.006] 11. Integer Arithmetic, Karatsuba Multiplication 整型算术,Karatsuba乘法

    很多人不喜欢√2的表达,他们认为它不是一个数. 一.卡塔兰数 Catalan numbers 在数方面上,有个著名的数叫卡塔兰数 Catalan numbers,它是组合数学中一个常在各种计数问题中出 ...

  9. startup乱码解决方法

    1.用记事本方式打开:‪apache-tomcat-8.5.59\conf\logging.properties 2.使用快捷键(Ctrl+H)把UTF-8全部替换为:GBK,进行保存(Ctrl+s) ...

  10. maven安装配置及其在IDEA和eclipse开发软件中配置

    1.maven下载安装 1.1.前往https://maven.apache.org/download.cgi下载最新版的Maven程序: 1.2.解压到本地,并配置环境变量 (1)path中添加 ( ...