CF1148D-Dirty Deeds Done Dirt Cheap
这轮CF怎么充满了替身啊233(这是场只有替身使者才能看见的比赛)
题解可以看官方的
这里就是记录下自己当初是怎么没做上的233
忽视掉了分类后pair本身就会带有的性质(a<b or a>b)
结果没发现排下序就好了。。。
可能当时就没想到自己能做出来D吧。。所以就理所当然地放弃了
现在看来,当题卡住的时候,不要怀疑自己,至少要想想有没有什么遗漏的性质才行……
#include<bits/stdc++.h>
#define N 300005
using namespace std;
int n,an,bn;
struct PP{
int a,b,id;
}A[N],B[N];
bool cmpa(PP A,PP B){return A.a>B.a;}
bool cmpb(PP A,PP B){return A.b<B.b;}
int main(){
scanf("%d",&n);
for(int i=,u,v;i<=n;i++){
scanf("%d%d",&u,&v);
if(u<v) A[++an]={u,v,i};
else B[++bn]={u,v,i};
}
if(an>bn){
printf("%d\n",an);
sort(A+,A++an,cmpa);
printf("%d",A[].id);
for(int i=;i<=an;i++)printf(" %d",A[i].id);
}
else{
printf("%d\n",bn);
sort(B+,B++bn,cmpb);
printf("%d",B[].id);
for(int i=;i<=bn;i++)printf(" %d",B[i].id);
}
return ;
}
CF1148D-Dirty Deeds Done Dirt Cheap的更多相关文章
- 使用Newtonsoft.Json.dll(JSON.NET)动态解析JSON、.net 的json的序列化与反序列化(一)
在开发中,我非常喜欢动态语言和匿名对象带来的方便,JSON.NET具有动态序列化和反序列化任意JSON内容的能力,不必将它映射到具体的强类型对象,它可以处理不确定的类型(集合.字典.动态对象和匿名对象 ...
- Codeforces Global Round 3
Codeforces Global Round 3 A. Another One Bites The Dust 有若干个a,有若干个b,有若干个ab.你现在要把这些串拼成一个串,使得任意两个相邻的位置 ...
- Using-JSONNET-for-dynamic-JSON-parsing
原文 https://weblog.west-wind.com/posts/2012/Aug/30/Using-JSONNET-for-dynamic-JSON-parsing With the re ...
- Codeforces Global Round 3(A-D)
我凉了..感觉自己啥都不会做,搞不好起床就绿了啊 代码和反思起床补,今天要反了个大思的 A. Another One Bites The Dust 把所有的ab排在一起然后两边叉a和b #includ ...
- Thinking Clearly about Performance
http://queue.acm.org/detail.cfm?id=1854041 The July/August issue of acmqueue is out now acmqueue is ...
- Meet Apache Wicket
第一次接触Wicket,如此多的内容是文字,的原贴,希望大家指正 Meet Apache Wicket By JonathanLocke, original author of Wicket 乔纳森· ...
- 8.3.2018 1 Quick and dirty 快而脏的快餐
Quick and dirty 快而脏的快餐 BEIJING 北京 Food delivery is a booming business. Waste is piling up, too 送餐 ...
- DevOps is dirty work - Dream in One-Click
真是一晃就到年底,年初许的梦想实现了吗?这么残忍的问题还是不要知道答案了吧:) 这恍若隔世的大半年,不仅没有承接着上篇继续聊Continuous Delivery (CD),反而疑似荒废.然而,梦想还 ...
- DevOps is dirty work - What's the deal
什么是DevOps?终于又回到这个最初的问题. 第一次看到这个词的时候,还身陷于各种敏捷概念轰炸中.用“身陷”这个词其实并不准确,因为那个年代的我也是那些热情洋溢地无处不宣传敏捷的热血文艺青年中的一员 ...
随机推荐
- [LeetCode][Java] 4Sum
题目: Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = ...
- Chrome 消息机制
Chrome浏览器扩展开发系列之十四:本地消息机制Native messaging 时间:2015-10-08 16:17:59 阅读:1560 评论:0 收藏:0 ...
- error: 'Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)'
[root@luozhonghua ~]# /usr/bin/mysqladmin -u root password 'aaaaaa' /usr/bin/mysqladmin: connect t ...
- oninput 中文输入
使用 input 监听 input 中文输入,会被每次输入的字母打断,下面就解决这个问题 $('input') .off() .on('input',function(){ if($(this).pr ...
- 基于二叉搜索树的符号表和BST排序
原代码例如以下: #include <stdlib.h> #include <stdio.h> //#define Key int typedef int Key; struc ...
- rel='canonical'
rel='canonical' <!DOCTYPE html><html><head> <meta charset="utf-8"/> ...
- ios6--UILabel
// // ViewController.m // 02-UILabel的使用 // // UILabel显示一段文字. #import "ViewController.h" @i ...
- 使用git命令 (git reset --hard HEAD) 回退版本信息
Git必须知道当前版本是哪个版本,在Git中,用HEAD表示当前版本,上一个版本就是HEAD^,上上一个版本就是HEAD^^,当然往上100个版本写100个^比较容易数不过来,所以写成HEAD~100 ...
- 51. ExtJs4之Ext.util.JSON编码和解码JSON对象
转自:https://blog.csdn.net/iteye_9439/article/details/82518158 1.decode() 该方法用于将符合JSON格式的String进行解码成为一 ...
- Android开发中常用的一些小技巧(转载)
http://www.jb51.net/article/61135.htm Activity.startActivities() 常用于在应用程序中间启动其他的Activity. TextUtils. ...