【Codeforces Round #431 (Div. 1) B】
【链接】h在这里写链接
【题意】
个点,它们分别向上与向右在不同时刻开始运动,相遇则改变移动方向,求最终这些点到达的坐标。
【题解】
【错的次数】
【反思】
【代码】
#include <bits/stdc++.h>
using namespace std; const int N = 1e5; int n, w, h, g[N + 10], p[N + 10], t[N + 10];
pair <int, int> ans[N + 10];
map <int, vector<int> > dic;
vector <int> vx, vy; void in() {
cin >> n >> w >> h; for (int i = 1; i <= n; i++) {
cin >> g[i] >> p[i] >> t[i];
dic[p[i] - t[i]].push_back(i);
}
} bool cmp(int x, int y) {
return p[x] < p[y];
} void get_ans() {
for (pair <int, vector<int> > temp : dic) {
int len = temp.second.size(); for (int i = 0; i <= len - 1; i++)
if (g[temp.second[i]] == 1) {
vx.push_back(temp.second[i]);
}
else {
vy.push_back(temp.second[i]);
} sort(vx.begin(), vx.end(), cmp);
sort(vy.begin(), vy.end(), cmp); int k = (int)vy.size() - 1 - (int)vx.size() + 1;
k = max(k, 0);
for (int i = (int)vy.size() - 1; i >= k; i--) {
int temp = (int)vy.size() - i - 1;
ans[vy[i]].first = p[vx[temp]], ans[vy[i]].second = h;
} for (int i = k - 1; i >= 0; i--) {
int temp = k - i;
ans[vy[i]].first = w, ans[vy[i]].second = p[vy[(int)vy.size() - temp]];
} k = (int)vx.size() - 1 - (int)vy.size() + 1;
k = max(k, 0);
for (int i = (int)vx.size() - 1; i >= k; i--) {
int temp = (int)vx.size() - i - 1;
ans[vx[i]].first = w, ans[vx[i]].second = p[vy[temp]];
} for (int i = k - 1; i >= 0; i--) {
int temp = k - i;
ans[vx[i]].first = p[vx[(int)vx.size() - temp]], ans[vx[i]].second = h;
}
vx.clear(), vy.clear();
}
} void out() {
for (int i = 1; i <= n; i++)
cout << ans[i].first << ' ' << ans[i].second << endl;
} int main() {
ios::sync_with_stdio(0), cin.tie(0);
in();
get_ans();
out();
return 0;
}
【Codeforces Round #431 (Div. 1) B】的更多相关文章
- 【Codeforces Round #431 (Div. 2) A】Odds and Ends
[链接]点击打开链接 [题意] 让你把一个数组分成奇数个部分. 且每个部分的长度都是奇数. [题解] 很简单的脑洞题. 开头和结尾一定要为奇数,然后 n为奇数的话,就选整个数组咯. n为偶数的话,不能 ...
- 【Codeforces Round #431 (Div. 2) B】 Tell Your World
[链接]点击打开链接 [题意] n个点,x从左到右严格递增的顺序给出 让你划两条平行的,且没有相同点的直线; 使得它们俩各自最少穿过一个点. 且它们俩穿过了所有的点. [题解] 枚举第一个点和哪个点组 ...
- 【Codeforces Round #431 (Div. 2) C】From Y to Y
[链接]点击打开链接 [题意] 让你构造一个大小最多为10W的字符multiset. 你进行n-1次操作; 每次操作,从set中取出两个字符串,一开始单个字符被认为是字符串. 然后把它们连接在一起. ...
- 【Codeforces Round #432 (Div. 1) B】Arpa and a list of numbers
[链接]h在这里写链接 [题意] 定义bad list是一个非空的.最大公约数为1的序列.给定一个序列,有两种操作:花费x将一个元素删除.花费y将一个元素加1,问你将这个序列变为good list所需 ...
- 【Codeforces Round 431 (Div. 2) A B C D E五个题】
先给出比赛地址啦,感觉这场比赛思维考察非常灵活而美妙. A. Odds and Ends ·述大意: 输入n(n<=100)表示长度为n的序列,接下来输入这个序列.询问是否可以将序列划 ...
- 【Codeforces Round #431 (Div. 1) D.Shake It!】
·最小割和组合数放在了一起,产生了这道题目. 英文题,述大意: 一张初始化为仅有一个起点0,一个终点1和一条边的图.输入n,m表示n次操作(1<=n,m<=50),每次操作是任选一 ...
- 【Codeforces Round #420 (Div. 2) C】Okabe and Boxes
[题目链接]:http://codeforces.com/contest/821/problem/C [题意] 给你2*n个操作; 包括把1..n中的某一个数压入栈顶,以及把栈顶元素弹出; 保证压入和 ...
- 【Codeforces Round #420 (Div. 2) B】Okabe and Banana Trees
[题目链接]:http://codeforces.com/contest/821/problem/B [题意] 当(x,y)这个坐标中,x和y都为整数的时候; 这个坐标上会有x+y根香蕉; 然后给你一 ...
- 【Codeforces Round #420 (Div. 2) A】Okabe and Future Gadget Laboratory
[题目链接]:http://codeforces.com/contest/821/problem/A [题意] 给你一个n*n的数组; 然后问你,是不是每个位置(x,y); 都能找到一个同一行的元素q ...
随机推荐
- 77.深入理解nodejs中Express的中间件
转自:https://blog.csdn.net/huang100qi/article/details/80220012 Express是一个基于Node.js平台的web应用开发框架,在Node.j ...
- 52. nodejs报错:Cannot find module 'ejs'
转自:https://blog.csdn.net/u010142437/article/details/79012605 错误显示: Error: Cannot find module 'ejs' ...
- 搭建Spark源码研读和代码调试的开发环境
转载自https://github.com/linbojin/spark-notes/blob/master/ide-setup.md 搭建Spark源码研读和代码调试的开发环境 工欲善其事,必先利其 ...
- 搭建并配置本地GitLab服务器教程
由于工作单位不一定能够方便使用外部网络,现以下载rpm包来搭建一套本地GitLab服务器. 1. 系统准备 系统:redhat 7.3 2. 下载所需安装包 去官网下rpm包,下载地址,ce是免费的社 ...
- 洛谷 P3111 [USACO14DEC]牛慢跑Cow Jog_Sliver
P3111 [USACO14DEC]牛慢跑Cow Jog_Sliver 题目描述 The cows are out exercising their hooves again! There are N ...
- ArcSDE:C#创建SDE要素数据集
转自原文 ArcSDE:C#创建SDE要素数据集 /// <summary> /// 判断指定数据集是否存在 /// </summary> /// <param name ...
- HDU 5371 (2015多校联合训练赛第七场1003)Hotaru's problem(manacher+二分/枚举)
pid=5371">HDU 5371 题意: 定义一个序列为N序列:这个序列按分作三部分,第一部分与第三部分同样,第一部分与第二部分对称. 如今给你一个长为n(n<10^5)的序 ...
- css大会站点顶部的一个特效
看到http://css.w3ctech.com/ 上一个效果认为挺赞的. 然后学些了一下. demo地址:http://codepen.io/tianzi77/pen/mJaLWq html结构非常 ...
- 27.Node.js模块系统
转自:http://www.runoob.com/nodejs/nodejs-module-system.html 为了让Node.js的文件可以相互调用,Node.js提供了一个简单的模块系统. 模 ...
- 5.使用SOAP的XML消息传递
转自:https://blog.csdn.net/u014066037/article/details/51724658 使用SOAP的XML消息传递的简易流程图: 详细步骤如下: (1)服务请求者的 ...