我凉了。。感觉自己啥都不会做,搞不好起床就绿了啊

代码和反思起床补,今天要反了个大思的

A. Another One Bites The Dust

把所有的ab排在一起然后两边叉a和b

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<vector>
#include<map>
#include<stdlib.h> #define fst first
#define sc second
#define pb push_back
#define mem(a,b) memset(a,b,sizeof(a))
#define lson l,mid,root<<1
#define rson mid+1,r,root<<1|1
#define lc root<<1
#define rc root<<1|1
#define lowbit(x) ((x)&(-x)) using namespace std; typedef double db;
typedef long double ldb;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PI;
typedef pair<ll,ll> PLL; const db eps = 1e-;
const int mod = 1e9+;
const int maxn = 2e6+;
const int maxm = 2e6+;
const int inf = 0x3f3f3f3f;
const db pi = acos(-1.0); int main(){
ll a, b,c;
scanf("%lld %lld %lld", &a, &b, &c);
ll ans = c*2ll;
ll tmp = min(a,b);
ans+=tmp*;
a-=tmp;b-=tmp;
if(a>||b>)ans++;
printf("%lld",ans);
return ;
}

B. Born This Way

题意:有n个从A到B的航班,m个从B到C的航班,要你删除k个使得到达C的最晚,求最晚时间

思路:删除的方式一定是前i个从A到B的,和k-i个最早从A到B之后能乘坐的B到C的航班。由于对于每个i,这个方案是惟一的,枚举即可。

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<vector>
#include<map>
#include<stdlib.h> #define fst first
#define sc second
#define pb push_back
#define mem(a,b) memset(a,b,sizeof(a))
#define lson l,mid,root<<1
#define rson mid+1,r,root<<1|1
#define lc root<<1
#define rc root<<1|1
#define lowbit(x) ((x)&(-x)) using namespace std; typedef double db;
typedef long double ldb;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PI;
typedef pair<ll,ll> PLL; const db eps = 1e-;
const int mod = 1e9+;
const int maxn = 3e6+;
const int maxm = 2e6+;
const int inf = 0x3f3f3f3f;
const db pi = acos(-1.0); ll a[maxn],b[maxn];
ll n,m,ta,tb,k;
ll mi[maxn],mx[maxn];
int main(){
scanf("%lld %lld %lld %lld %lld",&n, &m,&ta,&tb,&k);
for(int i = ; i <= n; i++){
scanf("%lld", &a[i]);a[i]+=ta;
}
for(int i = ; i <= m; i++){
scanf("%lld", &b[i]);
}ll res = -;
if(k>=n||k>=m)return printf("-1"),;
for(int i = ; i <= k; i++){
int t = k-i;
int p = lower_bound(b+,b++m,a[i+])-b;
p+=t;
if(p>m)return printf("-1"),;
else res = max(res, b[p]+tb);
}printf("%lld", res);
return ;
}

C. Crazy Diamond

题意:给你一个1-n的排列,每次选择两个位置i,j交换位置上的值,且满足2*|i-j|>=n,让你输出具体方案,使得operation不超过5n。

思路:根据限制条件,发现位置1和n合起来可以调动整个数组,而n/2和n/2+1位置只能分别和n和1交换,所以可以从中间开始向两边分别填充,操作不超过3n

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<vector>
#include<map> #define fst first
#define sc second
#define pb push_back
#define mem(a,b) memset(a,b,sizeof(a))
#define lson l,mid,root<<1
#define rson mid+1,r,root<<1|1
#define lc root<<1
#define rc root<<1|1
#define lowbit(x) ((x)&(-x)) using namespace std; typedef double db;
typedef long double ldb;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PI;
typedef pair<ll,ll> PLL; const db eps = 1e-;
const int mod = 1e9+;
const int maxn = 2e6+;
const int maxm = 2e6+;
const int inf = 0x3f3f3f3f;
const db pi = acos(-1.0); int n;
int a[maxn];
int id[maxn];
vector<PI>v;
void swp(int x, int y){
if(x==y)return;
int i = a[x];
int j = a[y];
swap(a[x],a[y]);
swap(id[i],id[j]);
v.pb({x,y});
}
int main() {
scanf("%d", &n);
for(int i = ; i <= n; i++){
scanf("%d", &a[i]);
id[a[i]]=i;
}
for(int i = n/; i >= ; i--){
int j = n-i+;
if(id[i]!=i){
if(id[i]<n/){
swp(n,id[i]);
}
else{
swp(,id[i]);
swp(n,);
}
swp(id[i],i);
} if(id[j]!=j){
if(id[j]>n/){
swp(,id[j]);
}
else{
swp(n,id[j]);
swp(n,);
}
swp(id[j],j);
}
}
//for(int i = 1; i <= n; i++)printf("%d ",a[i]);printf("\n");
printf("%d\n",v.size());
for(int i = ; i < (int)v.size(); i++){
printf("%d %d\n",v[i].fst,v[i].sc);
}
return ;
}

D. Dirty Deeds Done Dirt Cheap

题意:给你n个pair,让你取出其中一些排列,使得他们排成一行的数x1>x2<x3>x4<x5...或x1<x2>x3<x4>x5...,问这样排列最长的方案

思路:我好弱智啊。。对于pair内不等号方向相同的分别考虑,比如在每个pair都是x<y的时候,对ans中两个相邻的pair,都有x1<y1>x2<y2。因为y1>x1,所以我们让x1>x2就可以满足y1>x2,所以对该类所有pair排序即可,答案为倒序输出。。。同样地,对x>y的时候只需要排序后正序输出。。把这两种size大的输出即可

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<vector>
#include<map>
#include<stdlib.h> #define fst first
#define sc second
#define pb push_back
#define mem(a,b) memset(a,b,sizeof(a))
#define lson l,mid,root<<1
#define rson mid+1,r,root<<1|1
#define lc root<<1
#define rc root<<1|1
#define lowbit(x) ((x)&(-x)) using namespace std; typedef double db;
typedef long double ldb;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PI;
typedef pair<ll,ll> PLL; const db eps = 1e-;
const int mod = 1e9+;
const int maxn = 3e6+;
const int maxm = 2e6+;
const int inf = 0x3f3f3f3f;
const db pi = acos(-1.0); struct Node{
int x, y;
int id;
}node[maxn];vector<Node>a,b;
bool cmp(Node a, Node b){
if(a.x==b.x)return a.y<b.y;
return a.x<b.x;
}
int main(){
int n;
scanf("%d", &n);
for(int i = ; i <= n; i++){
node[i].id=i;
scanf("%d %d" ,&node[i].x, &node[i].y);
if(node[i].x<node[i].y)a.pb(node[i]);
else b.pb(node[i]);
}
printf("%d\n",max(a.size(), b.size()));
sort(a.begin(),a.end(),cmp);
sort(b.begin(),b.end(),cmp);
if(a.size()>b.size()){
for(int i = a.size()-; i>=; i--){
printf("%d ",a[i].id);
}
}
else{
for(int i = ; i < b.size(); i++)printf("%d ",b[i].id);
}
return ;
}

Codeforces Global Round 3(A-D)的更多相关文章

  1. CodeForces Global Round 1

    CodeForces Global Round 1 CF新的比赛呢(虽然没啥区别)!这种报名的人多的比赛涨分是真的快.... 所以就写下题解吧. A. Parity 太简单了,随便模拟一下就完了. B ...

  2. Codeforces Global Round 1 - D. Jongmah(动态规划)

    Problem   Codeforces Global Round 1 - D. Jongmah Time Limit: 3000 mSec Problem Description Input Out ...

  3. Codeforces Global Round 2 题解

    Codeforces Global Round 2 题目链接:https://codeforces.com/contest/1119 A. Ilya and a Colorful Walk 题意: 给 ...

  4. Codeforces Global Round 1 (A-E题解)

    Codeforces Global Round 1 题目链接:https://codeforces.com/contest/1110 A. Parity 题意: 给出{ak},b,k,判断a1*b^( ...

  5. Codeforces Global Round 3

    Codeforces Global Round 3 A. Another One Bites The Dust 有若干个a,有若干个b,有若干个ab.你现在要把这些串拼成一个串,使得任意两个相邻的位置 ...

  6. Codeforces Global Round 1 (CF1110) (未完结,只有 A-F)

    Codeforces Global Round 1 (CF1110) 继续补题.因为看见同学打了这场,而且涨分还不错,所以觉得这套题目可能会比较有意思. 因为下午要开学了,所以恐怕暂时不能把这套题目补 ...

  7. 【手抖康复训练1 】Codeforces Global Round 6

    [手抖康复训练1 ]Codeforces Global Round 6 总结:不想复习随意打的一场,比赛开始就是熟悉的N分钟进不去时间,2333,太久没写题的后果就是:A 题手抖过不了样例 B题秒出思 ...

  8. Codeforces Global Round 11 个人题解(B题)

    Codeforces Global Round 11 1427A. Avoiding Zero 题目链接:click here 待补 1427B. Chess Cheater 题目链接:click h ...

  9. 【Codeforces Round 1110】Codeforces Global Round 1

    Codeforces Round 1110 这场比赛只做了\(A\).\(B\).\(C\),排名\(905\),不好. 主要的问题在\(D\)题上,有\(505\)人做出,但我没做出来. 考虑的时候 ...

  10. 树形DP ---- Codeforces Global Round 2 F. Niyaz and Small Degrees引发的一场血案

    Aspirations:没有结果,没有成绩,acm是否有意义?它最大的意义就是让我培养快速理解和应用一个个未知知识点的能力. ————————————————————————————————————— ...

随机推荐

  1. Linux下安装oracle遇到启动监听服务器启动失败

    1.发现监听服务器没有启动,则  lsntctl start 启动监听服务器: 2.发现TNS-12555问题: 3.查找TNS-12555错误,找到一个满意的答案: chmod  777 /var/ ...

  2. 【Java并发基础】并发编程领域的三个问题:分工、同步和互斥

    前言 可以将Java并发编程抽象为三个核心问题:分工.同步和互斥. 这三个问题的产生源自对性能的需求.最初时,为提高计算机的效率,当IO在等待时不让CPU空闲,于是就出现了分时操作系统也就出现了并发. ...

  3. python如何计算程序(代码块)的运行时间?

    1.引入time模块 2.调用time模块的time()函数 :用来获取当前的时间,返回的单位是秒 # 引入一个time模块, * 表示time模块的所有功能, # 作用: 可以统计程序运行的时间 f ...

  4. Spring Boot2 系列教程(二十) | SpringBoot 是如何实现日志的?

    微信公众号:一个优秀的废人.如有问题,请后台留言,反正我也不会听. 前言 休息日闲着无聊看了下 SpringBoot 中的日志实现,把我的理解跟大家说下. 门面模式 说到日志框架不得不说门面模式.门面 ...

  5. 图解kubernetes服务打散算法的实现源码

    在分布式调度中为了保证服务的高可用和容灾需求,通常都会讲服务在多个区域.机架.节点上平均分布,从而避免单点故障引起的服务不可用,在k8s中自然也实现了该算法即SelectorSpread, 本文就来学 ...

  6. scope为provided

    以下面dependency为例 1 <dependency> 2 <groupId>javax.servlet</groupId> 3 <artifactId ...

  7. 【UWP】使用 LiteDB 存储数据

    序言: 在 UWP 中,常见的存储数据方式基本上就两种.第一种方案是 UWP 框架提供的 ApplicationData Settings 这一系列的方法,适用于存放比较轻量的数据,例如存个 Bool ...

  8. Django框架的初使用

    1Django框架的初使用 说起Django框架,肯定需要首先明确一个概念,即软件框架.下面就是第一个问题: 1 软件框架(software framework) 1.1 概念界定 软件框架:通常指的 ...

  9. [bzoj4827] [洛谷P3723] [Hnoi2017] 礼物

    Description 我的室友最近喜欢上了一个可爱的小女生.马上就要到她的生日了,他决定买一对情侣手 环,一个留给自己,一 个送给她.每个手环上各有 n 个装饰物,并且每个装饰物都有一定的亮度.但是 ...

  10. 使用Razor 使用Razor表达式处理命名空间 精通ASP-NET-MVC-5-弗瑞曼