https://codeforces.com/contest/1216/problem/A

A. Prefixes

题意大概就是每个偶数位置前面的ab数目要相等,很水,被自己坑了

1是没看见要输出修改后的字符串,2是修改的写反了。。3是忘记清零了?,生生把罚时拖的。。。

本来四分钟的题的。。然后罚时+10分钟过题,我晕了,以后还是要再认真一点,比如说把样例测完。。

 #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
int a=,b=,ans=,n;
string s;
ios::sync_with_stdio();
cin>>n;cin>>s;
for(int i = ;i < n;++i){
if(s[i]=='a')a++;
else if(s[i]=='b')b++;
if(i%){
if(a>b){
s[i]='b';ans++;
}
else if(a<b){
s[i]='a';ans++;
}
a = b = ;
}
} cout<<ans<<endl;
cout<<s<<endl;
return ;
}

AC代码

https://codeforces.com/contest/1216/problem/B

B. Shooting

也很简单,贪心+模拟,这题真的是秒写一发过,,但是我先去看c才回来写的b。。。头疼,被某个哥哥干扰了一波,,

题意是给你n和n个数,然后你按某个顺序排列,让Σai*(i-1)+1最小 ,最后输出总数和然后按原顺序输出你使用该数的”时刻“

emmm很明显就是从大到小排序然后直接算,没坑,直接写就完事了

 #include<bits/stdc++.h>
using namespace std;
struct ac{
int x,now;
}s[];
bool cmp(ac a,ac b){
return a.x>b.x;
}
int main(){
int n;
long long ans= ;
ios::sync_with_stdio();
cin>>n;
for(int i = ;i <= n;++i){
cin>>s[i].x;
s[i].now=i; }
sort(s+,s++n,cmp);
for(int i = ; i <= n;++i){
ans+=(s[i].x*(i-)+);
}
cout<<ans<<endl;
for(int i = ; i <= n;++i){
cout<<s[i].now<<" ";
}
return ;
}

AC代码

https://codeforces.com/contest/1216/problem/C

C. White Sheet

呜呜呜呜呜还是简单题啊,给你一张白纸和两张黑纸的坐标,让你判断黑纸是否将白纸完全覆盖了。

这题好像有人二维前缀和过了但是我没看懂,到时候再好好看看吧。

本来我是正向考虑,算出白纸面积,黑纸覆盖了哪一块就剪掉,,,,结果没考虑到黑纸重复部分然后又不想磨了。。

后面才发现如果只有一个角相交是没有办法完全覆盖,,,所以根本不需要那样写呜呜呜呜呜

把能够覆盖的几种情况列出来,剩下的就都能看见白纸了(参考rank1的写法

 #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
struct ac{
ll x1,y1,x2,y2;
}a[];
ll x1,x2,y1,y2,s,ss[];
int main(){ ios::sync_with_stdio();
cin>>x1>>y1>>x2>>y2;
s=(x2-x1)*(y2-y1); for(int i = ;i < ;++i){
cin>>a[i].x1>>a[i].y1>>a[i].x2>>a[i].y2;
ss[i]=(a[i].x2-a[i].x1)*(a[i].y2-a[i].y1);
}
if(ss[]+ss[] <s){
cout<<"YES"<<endl;return ;
}
if(a[].x1<=x1&&a[].y1<=y1&&a[].x2>=x2&&a[].y2>=y2){
cout<<"NO"<<endl;return ;
}
if(a[].x1<=x1&&a[].y1<=y1&&a[].x2>=x2&&a[].y2>=y2){
cout<<"NO"<<endl;return ;
}
if(a[].x1<=x1&&a[].x2>=x2&&a[].x1<=x1&&a[].x2>=x2)
{
if(a[].y1<=y1&&a[].y2>=a[].y1&&a[].y2>=y2){
cout<<"NO"<<endl;return ;
}
if(a[].y1<=y1&&a[].y2>=a[].y1&&a[].y2>=y2){
cout<<"NO"<<endl;return ;
}
}
if(a[].y1<=y1&&a[].y2>=y2&&a[].y1<=y1&&a[].y2>=y2){
if(a[].x1<=x1&&a[].x2>=a[].x1&&a[].x2>=x2){
cout<<"NO"<<endl;return ;
}
if(a[].x1<=x1&&a[].x2>=a[].x1&&a[].x2>=x2){
cout<<"NO"<<endl;return ;
}
}
cout<<"YES"<<endl;return ; }

AC代码

(好好记住这三种情况 下次碰见同类型的得反应快一点qwq

https://codeforces.com/contest/1216/problem/D

D. Swords

这题过的比c还多。。。。

没有证明出来为什么这样写是对的

反正就是用最大值减去当前值得到的差值求一个整体的gcd,然后再求一遍人数就好了

 #include<bits/stdc++.h>
using namespace std;
int a[];
int main(){
int n,cnt = ;
long long ans= ;
ios::sync_with_stdio();
cin>>n;
for(int i = ;i < n;++i)cin>>a[i];
sort(a,a+n);
for(int i = ;i < n;++i)cnt=__gcd(cnt,a[n-]-a[i]);
for(int i = ;i < n;++i)ans+=(a[n-]-a[i])/cnt;
cout<<ans<<" "<<cnt<<endl;
return ;
}

AC代码

Codeforces Round #587 (Div. 3)的更多相关文章

  1. Codeforces Round #587 (Div. 3) D. Swords

    链接: https://codeforces.com/contest/1216/problem/D 题意: There were n types of swords in the theater ba ...

  2. Codeforces Round #587 (Div. 3) C. White Sheet

    链接: https://codeforces.com/contest/1216/problem/C 题意: There is a white sheet of paper lying on a rec ...

  3. Codeforces Round #587 (Div. 3) B. Shooting(贪心)

    链接: https://codeforces.com/contest/1216/problem/B 题意: Recently Vasya decided to improve his pistol s ...

  4. Codeforces Round #587 (Div. 3) A. Prefixes

    链接: https://codeforces.com/contest/1216/problem/A 题意: Nikolay got a string s of even length n, which ...

  5. Codeforces Round #587 (Div. 3) F. Wi-Fi(单调队列优化DP)

    题目:https://codeforces.com/contest/1216/problem/F 题意:一排有n个位置,我要让所有点都能联网,我有两种方式联网,第一种,我直接让当前点联网,花费为i,第 ...

  6. Codeforces Round #587 (Div. 3) C题 【判断两个矩形是否完全覆盖一个矩形问题】 {补题 [差点上分系列]}

    C. White Sheet There is a white sheet of paper lying on a rectangle table. The sheet is a rectangle ...

  7. Codeforces Round #587 (Div. 3) F Wi-Fi(线段树+dp)

    题意:给定一个字符串s 现在让你用最小的花费 覆盖所有区间 思路:dp[i]表示前i个全覆盖以后的花费 如果是0 我们只能直接加上当前位置的权值 否则 我们可以区间询问一下最小值 然后更新 #incl ...

  8. Codeforces Round #366 (Div. 2) ABC

    Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate ...

  9. Codeforces Round #354 (Div. 2) ABCD

    Codeforces Round #354 (Div. 2) Problems     # Name     A Nicholas and Permutation standard input/out ...

随机推荐

  1. 闰年计算——JavaScript 语言计算

    ㈠闰年是如何来的? 闰年(Leap Year)是为了弥补因人为历法规定造成的年度天数与地球实际公转周期的时间差而设立的.补上时间差的年份为闰年. ㈡什么是闰年? 凡阳历中有闰日(二月为二十九日)的年, ...

  2. cursor(鼠标手型)属性

    ㈠简单介绍 在浏览网页时,通常看到的鼠标光标形状有箭头.手形.沙漏等,而在 windows 中实际看到的鼠标指针种类比这个还要多. 一般情况下,鼠标光标的形状由浏览器负责控制,大多数情况的光标形状为箭 ...

  3. Haystack全文检索框架

    一.什么是Haystack Haystack是django的开源全文搜索框架(全文检索不同于特定字段的模糊查询,使用全文检索的效率更高 ),该框架支持Solr,Elasticsearch,Whoosh ...

  4. 智能指针之shared_ptr基本概述

    1.shared_ptr允许有多个指针指向同一个对象,unique_ptr独占所指向的对象. 2.类似于vector,智能指针也是模板.创建智能指针: shared_ptr<string> ...

  5. Linux命令-磁盘管理(二)

    Linux命令-磁盘管理(二) Linux mmount命令 Linux mmount命令用于挂入MS-DOS文件系统. mmount为mtools工具指令,可根据[mount参数]中的设置,将磁盘内 ...

  6. 原生Js_实现简单的下拉折叠菜单(添加弹出动画效果)

    用javascript实现简单的下拉折叠菜单效果 实现步骤 (a)获得各操作的dom对象: (b)在所有菜单按钮对象上添加单击事件: (c)设置所有菜单按钮样式为空,并将当前按钮的样式设置为“acti ...

  7. python学习之路(2)(渗透信息收集)

    scapy的用法 通过目标ip的回复判断目标ip主机的情况 先写上三层的IP 四层的TCP 然后r.display看一下我们的包 src是源ip dst是目标ip 我们添加目标ip 这里是网关的ip ...

  8. html_javascript 基础操作

    <!DOCTYPE html> <html> <body> <h1>My Web Page</h1> <p id="demo ...

  9. git设置mergetool可视化工具

      可以设置BeyondCompare,DiffMerge等作为git的比较和合并的可视化工具,方便操作. 设置如下: 先下载并安装BeyondCompare,DiffMerge等. 设置git配置, ...

  10. nodejs 配置服务器

    node 是 js 的运行的后台环境,他自身集成了很多模块,集成的模块直接 require 就行了: npm 第三方平台,他也是为 node 服务的,对于 npm 中的模块,先 npm install ...