Educational Codeforces Round 43 (Rated for Div. 2)
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 )。要求你构造一个满足以下条件的无向图:
- 有恰好 dn+1 个点。
- 没有自环。
- 没有重边。
- 总边数不超过 10^6。
- 它的度数集合等于 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)的更多相关文章
- 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 ...
- 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 ...
- 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 ...
- Educational Codeforces Round 35 (Rated for Div. 2)
Educational Codeforces Round 35 (Rated for Div. 2) https://codeforces.com/contest/911 A 模拟 #include& ...
- 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 ...
- 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 ...
- Educational Codeforces Round 63 (Rated for Div. 2) 题解
Educational Codeforces Round 63 (Rated for Div. 2)题解 题目链接 A. Reverse a Substring 给出一个字符串,现在可以对这个字符串进 ...
- 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 < ...
- Educational Codeforces Round 48 (Rated for Div. 2) CD题解
Educational Codeforces Round 48 (Rated for Div. 2) C. Vasya And The Mushrooms 题目链接:https://codeforce ...
随机推荐
- 解除Portal for ArcGIS与ArcGIS Server的联合
将ArcGIS Server站点添加到Portal中,可以实现ArcGIS Server站点的单点登录特性,并可以与Portal共享Server站点发布的内容,同时通过将联合服务器注册为托管服务器后还 ...
- Ping 笔记
Ping 笔记 查看网络间的连通性. 当设备与PC在同一局域网中(连接同一路由器),设备与PC互Ping对方,若只有其中一个掉线连不上,两者可能存在网络端口的问题, 若设备与PC同时掉线,则为路由器 ...
- 微信小程序web-view的简单思考和实践
微信小程序的组件web-view推出有一段时间了,这个组件的推出可以说是微信小程序开发的一个重要事件,让微信小程序不会只束缚在微信圈子里了,打开了一个口子,这个口子或许还比较小,但未来有无限可能. 简 ...
- 羊车门问题(Python)
羊车门问题(结对作业) 在完成本题之前,请仔细阅读下面内容: 题目描述:有3扇关闭的门,一扇门后面停着汽车,其余门后是山羊,只有主持人知道每扇门后面是什么.参赛者可以选择一扇门,在开启它之前,主持人会 ...
- jmeter多sql查询
背景:实现多条sql语句,取多个值的情况 步骤:1.JDBC Connection Configuration配置添加?allowMultiQueries=true 2.增加sql语句 ,查询或修改语 ...
- JavaScript数组方法--slice、sort、splice
数组常用方法应该只剩下最后这哥仨了,他们都是最早的ECMA-262标准的方法,结果写着写着,居然把他们写到最后了. slice:slice() 方法返回一个新的数组对象,这一对象是一个由 begin和 ...
- vs 为什么使用#include "stdafx.h"
原因:1.减少编译次数 2.减少不必要的处理 流程图: 这个跟宏定义#ifndef xx #define xx coding here #endif //xx 区别在于: 宏定义是防止头文件重复包含 ...
- 2018-2019-2 20165205 《网络对抗技术》 Exp1 PC平台逆向破解
2018-2019-2 20165205 <网络对抗技术> Exp1 PC平台逆向破解 1. 实验任务 1.1实验概括 用一个pwn1文件. 该程序正常执行流程是:main调用foo函数, ...
- stm32 HAL库笔记(一)——串口的操作
昨天分析了普通io口的使用,和初始化代码流程,回顾一下,首先定义一个配置io口功能的结构体,然后开启时钟,再去配置这个结构体里面的各个成员变量,每个成员变量都有很多种选择,可以看各个成员变量 后面的注 ...
- java高并发实战(一)——为什么需要并发
转自:https://blog.csdn.net/gududedabai/article/details/80813592