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 ...
随机推荐
- JSP中EL表达式不能使用的问题
在JSP2.0中,增加了EL语言,可以通过EL语言,可以通过EL语言,实现获取数据,进一步将scriptlet 代码从JSP页面中分离出来.EL语言给大家带来了方便,但有时,也会遇到EL表达式不能显示 ...
- vue的基础数据绑定
todo https://www.jb51.net/article/132344.htm
- 一、mybatis的插件介绍
摘自:https://www.cnblogs.com/qm-article/p/11785350.html mybatis的插件机制 一.mybatis的插件介绍 关于mybatis的插件,我想大 ...
- Mac安装ipython与jupyter
Python从Python发展而来,更倾向于科学计算.互联网数据分析更喜欢用. 首先切换root用户: sudo su - pip3自动安装ipython yuchaodeMacBook-Pro:~ ...
- TL;DR
英文文章中,偶尔会出现TL;DR 的字符. TL;DR=>Too Long; Don’t Read=>太长了,读不下去=>长话短说 一般用于在文章开头先给出干货.
- 20175212童皓桢 实验三敏捷开发与XP实践实验报告
20175212童皓桢 实验三敏捷开发与XP实践实验报告 实验内容 XP基础 XP核心实践 相关工具 实验步骤 一.Code菜单功能的研究 Move Line/statement Down/Up:将某 ...
- Spring Boot中使用 Thymeleaf
目录 1.pom.xml引入thymeleaf 2.关闭缓存application.properties 3.编写Controller类 4.模板html 5.运行结果 1.pom.xml引入thym ...
- 190707Python-Redis
一.Redis的简单使用 Redis操作模式 # Author:Li Dongfei import redis r = redis.Redis(host='192.168.56.7', port=63 ...
- 全面解读php-常量及数据类型
本文主要讲解字符串的定义方式,数据类型和常量的相关内容. 一.字符串的定义方式 1.字符串的定义方式除了单双引号外,还有一种叫 heredoc 和 newdoc 在我们需要定义很长一段儿字符串的时候 ...
- N2RR
一.背景 氨(NH 3)是一种新兴的能量载体,在液氨中含有17.6%(重量)的氢,而在甲醇中的含量为12.5%(重量),很可能成为未来氢能经济的有希望的候选者.然而,如果基于NH 3的肥料不足以养活世 ...