续 Codeforces 605 B
来源:互联网 发布:淘宝网店客服怎么做 编辑:程序博客网 时间:2024/05/01 15:41
不得不说此题的这种解法比我的逼格高10000倍啊,巧妙地利用过了取反来,用vector排序,而且还迭代器,还auto,而且make_pair的时候也是直接上{},不行不行,思维一定要变通,姿势一定要优美
#include<bits/stdc++.h>using namespace std;const int MAX=1e5+9;int n,m,p1=1,p2=2,p3=1;pair<int,int> ans[MAX];vector<pair<pair<int,int>,int> > edge;int main(){ cin>>n>>m; for (int i=0,w,t;i<m;i++) cin>>w>>t,edge.push_back({{w,-t},i}); sort(edge.begin(),edge.end()); for (auto e:edge) { if (e.first.second==-1) ans[e.second]={0,p1},p1++; else { if (p3==0) p2++,p3=p2-1; if (p2>=p1 || p3==0) return cout<<-1,0; ans[e.second]={p2,p3},p3--; } } for (int i=0;i<m;i++) cout<<ans[i].first+1<<" "<<ans[i].second+1<<'\n';}
0 0
- 续 Codeforces 605 B
- Codeforces 605B 构造
- Codeforces 605B Lazy Student
- 续 codeforces 613B Skills
- codeforces B
- codeforces B
- codeforces B
- codeforces B
- 605B. Lazy Student(codeforces Round 335)
- [CodeForces 605B]Lazy Student[贪心][构造]
- CodeForces 605 B.Lazy Student(构造)
- CodeForces 626B CodeForces 626B【暴力】
- CodeForces 841B (B) 博弈
- codeforces 134B
- codeforces#98 b
- codeforces 105 div2 B
- Codeforces 166B - Polygons
- codeforces B. Coins
- Maven构建web项目常用配置
- 1/17||1/18
- CentOS 7中没有ifconfig命令,而且不能发现eth0
- 欢迎使用CSDN-markdown编辑器
- C++小题(十五)
- 续 Codeforces 605 B
- 分享 个人喜欢的几个谈论 React Native的几个知乎问题地址
- UNIX-静态库和动态库,环境变量
- Maven安装
- file.getPath() getAbsolutePath() getCanonicalPath()区别
- 获取系统信息的函数
- 未排序数组中累加和为给定值的最长子数组
- 一些感想
- CC2540 CC2541 CC2530脱机烧录器量产批量生产设备 2路并行烧录