Codeforces Round #587 (Div. 3)
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)的更多相关文章
- Codeforces Round #587 (Div. 3) D. Swords
链接: https://codeforces.com/contest/1216/problem/D 题意: There were n types of swords in the theater ba ...
- 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 ...
- Codeforces Round #587 (Div. 3) B. Shooting(贪心)
链接: https://codeforces.com/contest/1216/problem/B 题意: Recently Vasya decided to improve his pistol s ...
- Codeforces Round #587 (Div. 3) A. Prefixes
链接: https://codeforces.com/contest/1216/problem/A 题意: Nikolay got a string s of even length n, which ...
- Codeforces Round #587 (Div. 3) F. Wi-Fi(单调队列优化DP)
题目:https://codeforces.com/contest/1216/problem/F 题意:一排有n个位置,我要让所有点都能联网,我有两种方式联网,第一种,我直接让当前点联网,花费为i,第 ...
- 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 ...
- Codeforces Round #587 (Div. 3) F Wi-Fi(线段树+dp)
题意:给定一个字符串s 现在让你用最小的花费 覆盖所有区间 思路:dp[i]表示前i个全覆盖以后的花费 如果是0 我们只能直接加上当前位置的权值 否则 我们可以区间询问一下最小值 然后更新 #incl ...
- 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 ...
- Codeforces Round #354 (Div. 2) ABCD
Codeforces Round #354 (Div. 2) Problems # Name A Nicholas and Permutation standard input/out ...
随机推荐
- C# 获取文件信息
string fullPath = @"d:\test\default.avi"; string filename = Path.GetFileName(fullPath);//返 ...
- 在线PDU格式编码/解码
在线PDU格式编码/解码 使用GSM/GPRS AT指令发送中文短信,汉字时,需要先将短信内容编码成PDU格式,然后通过AT+CMGS AT+CMGW等指令发送. 注意:需要先通过AT+CMG ...
- Unity3D_(数据)LitJson创建和解析Json
LitJson github: 传送门 JsonUtility创建和解析Json 传送门 LitJson.dll百度云盘 传送门 密码:p1py 加载LitJson.dll到Unity中 在Asset ...
- javascript学习笔记之DOM
DOM(文档对象模型),描述了一个层次化的节点树 一.DOM NODE相关公共属性与方法 DOM中所有节点都实现了NODE接口,该接口的公共属性和方法如下: 1.节点基本属性 1)NodeType 节 ...
- ValueError: Unable to determine SOCKS version from socks://127.0.0.1:1080/
使用ss之后输入conda指令出现错误:“ValueError: Unable to determine SOCKS version from socks://127.0.0.1:1080/”. 解决 ...
- debug1: Could not open authorized keys
ssh登录的时候一直日志一直出现debug1: Could not open authorized keys登录不上,检查文件夹权限都正常用这条命令解决了 restorecon -FRvv /home ...
- vim 配置 scala 语法高亮
第一步:执行下面这个命令: mkdir -p ~/.vim/{ftdetect,indent,syntax}for d in ftdetect indent syntax ; do curl -o ~ ...
- layer实现关闭弹出层刷新父界面功能详解
本文实例讲述了layer实现关闭弹出层刷新父界面功能.分享给大家供大家参考,具体如下: layer是一款近年来备受青睐的web弹层组件,她具备全方位的解决方案,致力于服务各水平段的开发人员,您的页面会 ...
- gromacs2018使用踩坑记--grompp 为啥要用-r
1. GMX grompp 概要 gmx grompp [ -f [<.mdp>] ] [ -c [<.gro / .g96 / ...>] ] [ -r [<.gro ...
- leetcode227 基本计算器
1先利用符号栈转化为逆波兰表达式,并添加‘,’作为一个数字的结尾: 2然后利用数字栈计算逆波兰表达式的值: class Solution { public: int calculate(string ...