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 ...
随机推荐
- HDU 6438 Buy and Resell ( 2018 CCPC 网络赛 && 贪心 )
题目链接 题意 : 给出一些数.你可以从左到右对这些数进行三种操作花费 Ai 买入东西.以 Ai 价格卖出你当前有的东西.或者什么都不做.现在问你可以获取的最大利益是多少? 分析 : 和 CF 867 ...
- FJOI2017前做题记录
FJOI2017前做题记录 2017-04-15 [ZJOI2017] 树状数组 问题转化后,变成区间随机将一个数异或一,询问两个位置的值相等的概率.(注意特判询问有一个区间的左端点为1的情况,因为题 ...
- 彩色图像--色彩空间 CMY(K)空间
学习DIP第63天 转载请标明本文出处:***http://blog.csdn.net/tonyshengtan ***,出于尊重文章作者的劳动,转载请标明出处!文章代码已托管,欢迎共同开发:http ...
- CF1213D Equalizing by Division
easy version hard version 问题分析 直接从hard version入手.不难发现从一个数\(x\)能得到的数个数是\(O(\log x)\)的.这样总共有\(O(n\log ...
- 导数与微分简单总结(updated)
只讲一些导数在OI中的简单应用,特别基础的东西,不会很详细也不会很全面. 导数的定义 设函数\(y=f(x)\)在点\(x_0\)的某个邻域内有定义,当自变量\(x\)在\(x_0\)处有增量\(Δx ...
- 整合spring之后,struts2里面的自定义拦截器的invocation.invoke()总是返回input
这个真的是整死我了,还好看见了一篇博客提示了我, 解决方法: 在spring的bean配置中我没有设置action的作用域为prototype,也就是多例的,如果不设置则就会是默认的singleton ...
- TCP层bind系统调用的实现分析
说明:该文章中部分代码未能完全理解透彻,可能对您造成误解,请慎读: 并建议您先阅读本博另外一篇文章:<Linux TCP套接字选项 之 SO_REUSEADDR && SO_RE ...
- 第十二周Java学习总结
学习总结: 本周主要学习了其他容器和事件处理 1.窗体事件(WindowListener)常用接口方法voidwindowActivated/windowDeactivated(WindowEvent ...
- numpy小记
import numpy as np # a=np.array([[1,3,2],[4,5,6]]) print(a) a=np.arange(1,13).reshape((3,4))#生成一个3行4 ...
- SpringBoot 2.x 使用Redis作为项目数据缓存
一.添加依赖 <!-- 添加缓存支持 --> <dependency> <groupId>org.springframework.boot</groupId& ...