【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 ...
随机推荐
- JBoss配置连接池
什么是数据库连接池? 配置连接池为的是解决效率问题.由于每创建一个连接都是非常耗时的,有了连接池,就能够提前放一些连接进去.以后我们再用连接就去连接池里面取而不是每次都创建.可是我们知道连接池是有上限 ...
- Codeforces 240E. Road Repairs 最小树形图+输出路径
最小树形图裸题,只是须要记录路径 E. Road Repairs time limit per test 2 seconds memory limit per test 256 megabytes i ...
- json和XML
发请求(url) 1.client ---------------->服务端 发送数据(Json/xml) < - ...
- HTML标签大全(常用)
转自:https://www.cnblogs.com/moije/p/6751624.html 文本标记语言,即HTML(Hypertext Markup Language),是用于描述网页文档的一种 ...
- es6 -- Iterator 和 for...of 循环
1:Iterator(遍历器)的概念 JavaScript 原有的表示“集合”的数据结构,主要是数组(Array)和对象(Object),ES6 又添加了Map和Set.这样就有了四种数据集合,用户还 ...
- 图形界面备份Linux系统介绍
详情见: http://os.51cto.com/art/200905/125680.htm 虽然Linux 是一个高度可靠的操作系统,但对于现在复杂的internet环境下, ...
- BOOT项目依赖另外一个模块的包,开发的时候都正常,执行clean package打包成jar时却提示依赖的模块包不存在。
我在service1模块里依赖了common模块,开发的时候包都能正常引用到,启动也能正常测试访问,可是奇怪的是,当我要打包成jar包时,就提示service1里依赖common的包都不存在,之前从没 ...
- Python datetime time 等时间 日期 之间的计算和相互转化
from datetime import datetime, date, timedelta, timezone from time import time, ctime, localtime, st ...
- [PWA] Deal with caches in PWA
The takeway is to know when we should cache the content? When we should clean the caches? 1. When sh ...
- SICP 习题 (1.39)解题总结
SICP 习题1.39沿着习题1.37, 1.38的方向继续前行,要求我们依据德国数学家J.H.Lambert的公式定义tan-cf过程,用于计算正切函数的近似值. J.H.Lambert的公式例如以 ...