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. c# 使用Split分割 换行符

    c# 使用Split分割 换行符,方法如下(其余方法有空再添加): string str = "aa" + "\r\n" + "bb"; s ...

  2. 计算机网络(十),HTTP的关键问题

    目录 1.在浏览器地址栏键入URL,按下回车之后经历的流程 2.HTTP状态码 3.GET请求和POST请求的区别 4.Cookie和Session的区别 5.IPV4和IPV6 十.HTTP的关键问 ...

  3. 静态库lib、动态库dll基础

    首先从hello world!开始 //main.cpp文件 void cpu(); int main() { put(); ; } 在main.cpp中定义了一个cpu():函数,但没有实现其功能, ...

  4. Win10升级后VMWare内的系统连不了网如何解决

    一些既想要体验新系统又不愿放弃旧系统的用户,一般都会在电脑中安装VMWare虚拟机.不过,他们偶尔也会遇到这样一个问题,当win10系统自动升级后,VMWare虚拟机内的系统就会出现无法连接网络的情况 ...

  5. JavaWeb_响应和请求数据包

    Google浏览器 F12中Network->Header部分 <%@ page language="java" import="java.util.*&qu ...

  6. input(移动端iOS)输入内容时调用软件盘后页面底部留白问题

    iOS/input输入框调用软键盘底部留白 只需input输入框失去焦点时,让页面自动下移即可恢复 <input placeholder="请输入用户名" v-model=& ...

  7. Ruby Programming学习笔记

    #将ARGV[0]转换成正则表达式类型 pattern= Regexp.new(ARGV[0]) #Devise gem包 Devise是Ruby中使用最广泛的身份验证gem包之一.Devise为我们 ...

  8. echarts折线图,纵坐标数值显示不准确的问题解决

    问题如图: 问题解决:将stack去掉或注释 如下图:

  9. 关于ArrayList的越界问题?

    大家都知道 ArrayList是自动扩容的. 那为什么会存在越界问题? 话不多说 上代码 package test; import java.util.ArrayList; public class ...

  10. java导入导出下载Excel,xls文件(带下拉框)

    /** * 导入excel文件 * 2014-7-23 * @return */ @RequiresPermissions("plug:product:caiwu:upload") ...