Educational Codeforces Round 43 (Rated for Div. 2)

https://codeforces.com/contest/976

A

 #include<bits/stdc++.h>
using namespace std;
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define IT set<ll>::iterator
#define sqr(x) ((x)*(x))
#define pb push_back
#define eb emplace_back
#define maxn 200005
#define eps 1e-8
#define pi acos(-1.0)
#define rep(k,i,j) for(int k=i;k<j;k++)
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll>pll;
typedef pair<ll,int> pli;
typedef pair<pair<int,string>,pii> ppp;
typedef unsigned long long ull;
const long long MOD=;
const double oula=0.57721566490153286060651209;
using namespace std; int main(){
std::ios::sync_with_stdio(false);
int n;
string str;
cin>>n>>str;
if(str=="") cout<<<<endl;
else {
int co=;
for(int i=;i<str.length();i++){
if(str[i]=='') co++;
}
cout<<;
for(int i=;i<co;i++){
cout<<;
}
cout<<endl;
}
}

B

 #include<bits/stdc++.h>
using namespace std;
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define IT set<ll>::iterator
#define sqr(x) ((x)*(x))
#define pb push_back
#define eb emplace_back
#define maxn 200005
#define eps 1e-8
#define pi acos(-1.0)
#define rep(k,i,j) for(int k=i;k<j;k++)
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll>pll;
typedef pair<ll,int> pli;
typedef pair<pair<int,string>,pii> ppp;
typedef unsigned long long ull;
const long long MOD=;
const double oula=0.57721566490153286060651209;
using namespace std; int main(){
std::ios::sync_with_stdio(false);
ll n,m,k;
cin>>n>>m>>k;
if (k<n) {
cout<<k+<<" "<<<<endl;
return ;
}
k-=n-;
if (k==) {
cout<<n<<" "<<;
return ;
}
k-=;
ll l=k/(m-);
k%=(m-);
if((n-l)%==) cout<<n-l<<" "<< k+<<endl;
else cout<<n-l<<" "<<m-k<<endl;
}

C

题意:是否存在一条线段是否包含另一条线段,有的话就输出其中一个解

思路:sort排序下即可

 #include<bits/stdc++.h>
using namespace std;
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define IT set<ll>::iterator
#define sqr(x) ((x)*(x))
#define pb push_back
#define eb emplace_back
#define maxn 200005
#define eps 1e-8
#define pi acos(-1.0)
#define rep(k,i,j) for(int k=i;k<j;k++)
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll>pll;
typedef pair<ll,int> pli;
typedef pair<pair<int,string>,pii> ppp;
typedef unsigned long long ull;
const long long MOD=;
const double oula=0.57721566490153286060651209;
using namespace std; vector<pair<int,pair<int,int> > >ve; bool cmp(pair<int,pair<int,int> > a,pair<int,pair<int,int> > b){
if(a.second.first==b.second.first) return a.second.second>b.second.second;
return a.second.first<b.second.first;
} int main(){
std::ios::sync_with_stdio(false);
int n;
cin>>n;
int x,y;
for(int i=;i<=n;i++){
cin>>x>>y;
ve.pb({i,{x,y}});
}
sort(ve.begin(),ve.end(),cmp);
int L=ve[].second.first,R=ve[].second.second,pos=ve[].first;
int flag=;
for(int i=;i<ve.size();i++){
if(L<=ve[i].second.first&&R>=ve[i].second.second){
cout<<ve[i].first<<" "<<pos<<endl;
return ;
}
L=ve[i].second.first,R=ve[i].second.second,pos=ve[i].first;
}
if(!flag){
cout<<-<<" "<<-<<endl;
}
}

D

题意:

给你一个长度为 n 的正整数序列 d1​,d2​,⋯,dn​ (d1​<d2​<⋯<dn​ )。要求你构造一个满足以下条件的无向图:

  1. 有恰好 dn​+1 个点。
  2. 没有自环。
  3. 没有重边。
  4. 总边数不超过 10^6。
  5. 它的度数集合等于 dd 。

点从 1标号至 dn​+1 。

图的度数序列是一个长度与图的点数相同的数组 a,其中 ai​ 是第 i 个顶点的度数(与其相邻的顶点数)。图的度数集合是度数序列排序后去重的结果。

思路:把前d[1]个点向所有点连接一条边后,就会出现有d[1]个度为d[n]的点,剩下的点度都为d[1],然后我们可以继续构造(d[2]-d[1],d[3]-d[1],d[4]-d[1]....d[n-1]-d[1])的点,不断缩小子问题

 #include<bits/stdc++.h>
using namespace std;
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define IT set<ll>::iterator
#define sqr(x) ((x)*(x))
#define pb push_back
#define eb emplace_back
#define maxn 200005
#define eps 1e-8
#define pi acos(-1.0)
#define rep(k,i,j) for(int k=i;k<j;k++)
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll>pll;
typedef pair<ll,int> pli;
typedef pair<pair<int,string>,pii> ppp;
typedef unsigned long long ull;
const long long MOD=;
const double oula=0.57721566490153286060651209;
using namespace std; vector<pii>ve;
int d[]; int main(){
std::ios::sync_with_stdio(false);
int n;
cin>>n;
for(int i=;i<=n;i++) cin>>d[i];
int L=,R=n;
int co=;
while(L<=R){
for(int i=d[L-]+;i<=d[L];i++){
for(int j=i+;j<=d[R]+;j++){
ve.pb({i,j});
co++;
}
}
L++;
R--;
}
cout<<co<<endl;
for(int i=;i<ve.size();i++){
cout<<ve[i].first<<" "<<ve[i].second<<endl;
}
}

E

题意:你有n个小兵,每个小兵都有血条和攻击力,你可以使用a种1操作,b种2操作,是小兵们的攻击力之和最大。1操作:是一个小兵当前血量翻倍 。2操作:把一个小兵当前的血量值赋值给攻击力。

思路:容易想到,把a操作的都给集中给一个小兵是最好的,所以我们可以先按血量-攻击力的差值从大到小排序,然后不断分情况枚举a给谁最好。

 #include<bits/stdc++.h>
using namespace std;
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define IT set<ll>::iterator
#define sqr(x) ((x)*(x))
#define pb push_back
#define eb emplace_back
#define maxn 200005
#define eps 1e-8
#define pi acos(-1.0)
#define rep(k,i,j) for(int k=i;k<j;k++)
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll>pll;
typedef pair<ll,int> pli;
typedef pair<pair<int,string>,pii> ppp;
typedef unsigned long long ull;
const long long MOD=;
const double oula=0.57721566490153286060651209;
using namespace std; ll n,a,b;
vector<pll>ve; bool cmp(pll a,pll b){
return a.first-a.second>b.first-b.second;
} int main(){
std::ios::sync_with_stdio(false);
ll x,y;
cin>>n>>a>>b;
b=min(b,n);
for(int i=;i<=n;i++){
cin>>x>>y;
ve.pb({x,y});
}
sort(ve.begin(),ve.end(),cmp);
ll sum=;
for(int i=;i<b;i++){
sum+=max(ve[i].first,ve[i].second);
}
for(int i=b;i<n;i++){
sum+=ve[i].second;
}
ll ans=sum;
for(int i=;i<b;i++){
ans=max(ans,sum-max(ve[i].first,ve[i].second)+(ve[i].first<<a));
}
sum-=max(ve[b-].first,ve[b-].second)-ve[b-].second;
if(b){
for(int i=b;i<n;i++){
ans=max(ans,sum-ve[i].second+(ve[i].first<<a));
}
}
cout<<ans<<endl;
}

F

待补

Educational Codeforces Round 43 (Rated for Div. 2)的更多相关文章

  1. Educational Codeforces Round 43 (Rated for Div. 2) ABCDE

    A. Minimum Binary Number time limit per test 1 second memory limit per test 256 megabytes input stan ...

  2. Educational Codeforces Round 60 (Rated for Div. 2) - C. Magic Ship

    Problem   Educational Codeforces Round 60 (Rated for Div. 2) - C. Magic Ship Time Limit: 2000 mSec P ...

  3. Educational Codeforces Round 60 (Rated for Div. 2) - D. Magic Gems(动态规划+矩阵快速幂)

    Problem   Educational Codeforces Round 60 (Rated for Div. 2) - D. Magic Gems Time Limit: 3000 mSec P ...

  4. Educational Codeforces Round 35 (Rated for Div. 2)

    Educational Codeforces Round 35 (Rated for Div. 2) https://codeforces.com/contest/911 A 模拟 #include& ...

  5. Codeforces Educational Codeforces Round 44 (Rated for Div. 2) F. Isomorphic Strings

    Codeforces Educational Codeforces Round 44 (Rated for Div. 2) F. Isomorphic Strings 题目连接: http://cod ...

  6. Codeforces Educational Codeforces Round 44 (Rated for Div. 2) E. Pencils and Boxes

    Codeforces Educational Codeforces Round 44 (Rated for Div. 2) E. Pencils and Boxes 题目连接: http://code ...

  7. Educational Codeforces Round 63 (Rated for Div. 2) 题解

    Educational Codeforces Round 63 (Rated for Div. 2)题解 题目链接 A. Reverse a Substring 给出一个字符串,现在可以对这个字符串进 ...

  8. Educational Codeforces Round 39 (Rated for Div. 2) G

    Educational Codeforces Round 39 (Rated for Div. 2) G 题意: 给一个序列\(a_i(1 <= a_i <= 10^{9}),2 < ...

  9. Educational Codeforces Round 48 (Rated for Div. 2) CD题解

    Educational Codeforces Round 48 (Rated for Div. 2) C. Vasya And The Mushrooms 题目链接:https://codeforce ...

随机推荐

  1. 搭建vsftpd服务

    配置文件 anonymous_enable=NOlocal_enable=YESwrite_enable=YESlocal_umask=022dirmessage_enable=YESxferlog_ ...

  2. python 操作excel

    操作excel安装的三种方式: 1.pip instaill xlwt    #写excel   pip instaill  xlrd    #读excel      pip instaill  xl ...

  3. win10家庭版,双击bat文件无法运行(double click bat file does not execute)

    win10家庭版,双击bat文件无法运行,弹出文件打开方式选择框. 在网上搜索处理办法,试了以下方法1-5都没有成功,用方法6规避. 方法1:打开一个驱动器,点“工具-文件夹选项→文件类型→新建→扩展 ...

  4. ReSharper 自动选中

    想让智能提示默认选中第一个,步骤:ReSharper->Options->如下图

  5. IP池验证IP是否可用 及scrapy使用 ip池

    简单验证 import requests url = "http://www.baidu.com/"proxies = {"http": "http: ...

  6. nginx mac

    ==> nginx Docroot is: /usr/local/var/www The default port has been set in /usr/local/etc/nginx/ng ...

  7. python 给定数组任意组合等于一个定值的所有解

    抛出问题: 求给定数组任意组合等于一个定值的所有解 例如列表l = [1, 2, 3, 4, 5],求任意组合的结果为10的所有答案 问题分析: 实际就是列表的所有排列组合,然后算出每个排列组合的值, ...

  8. 2018-2019-2 20165205 Exp2 后门原理与实践

    20165205 Exp2 后门原理与实践 实验内容 一.基础问题回答 列举你能想到的一个后门进入到你系统中的可能方式 下载盗版软件.操作系统 当然正版软件里可能也有编写者安装的后门 不在官方更新软件 ...

  9. leetcode每日刷题计划-简单篇day8

    今天是纠结要不要新买手机的一天QAQ想了想还是算了吧,等自己赚钱买,加油 Num 70 爬楼梯 Climbing Stairs class Solution { public: int climbSt ...

  10. 练习: bs4 简单爬取 + matplotlib 折线图显示 (关键词,职位数量、起薪)

    要看一种技术在本地的流行程度,最简单的就是找招聘网站按关键词搜索. 比如今天查到的职位数量是vue 1296个,react 1204个,angular 721个.国际上比较流行的是react,本地市场 ...