大致题意:

      有一个W*H的长方形,有n个人,分别站在X轴或Y轴,并沿直线向对面走,第i个人在ti的时刻出发,如果第i个人与第j个人相撞了

    那么则交换两个人的运动方向,直到走到长方形边界停止,问最后每个人的坐标。

    

    题解:

      两个人要相撞,当且仅当Xi-Ti=Xj-Tj,所以可以将Xi-Ti分组,对于同一组里的人会互相碰撞,不同组的不会,这样就只要考虑同一组里

    的人,画个图可以发现,规律

    然后根据规律化坐标即可

    

 #include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<map>
using namespace std;
#define eps 1e-6
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Fore(i,a,b) for(int i=a;i>=b;i--)
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define mkp make_pair
#define pb push_back
#define sz size()
#define met(a,b) memset(a,b,sizeof(a))
#define iossy ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define fr freopen
#define pi acos(-1.0)
#define Vector Point
typedef pair<int,int> pii;
const long long linf=1LL<<;
const int iinf=<<;
const double dinf=1e17;
const int Mod=1e9+;
typedef long long ll;
typedef long double ld;
const int maxn=;
struct node{
int x,t,g;
int id;
};
bool cmp(node a,node b){
if(a.g==b.g){
if(a.g==) return a.x<b.x;
if(a.g==) return a.x>b.x;
}
return a.g<b.g;
}
bool cmp2(node a,node b){
if(a.g==b.g) {
if(a.g==) return a.x<b.x;
return a.x>b.x;
}
return a.g>b.g;
}
const int maxt=;
vector<node>vc[maxn];
vector<pair<int,int> >vcc;
pii p,ans[maxn];
node nd;
int n,w,h;
void solve(){
iossy;
cin>>n>>w>>h;
For(i,,n){
cin>>nd.g>>nd.x>>nd.t;nd.id=i;
vc[maxt+nd.x-nd.t].pb(nd);
}
For(i,,maxt+maxt){
vcc.clear();
if(!vc[i].sz)continue;
sort(vc[i].begin(),vc[i].end(),cmp);
For(j,,vc[i].sz){
if(vc[i][j-].g==) vcc.pb(mkp(vc[i][j-].x,h));
else vcc.pb(mkp(w,vc[i][j-].x));
}
sort(vc[i].begin(),vc[i].end(),cmp2);
For(j,,vc[i].sz){
ans[vc[i][j-].id]=vcc[j-];
}
}
For(i,,n)
cout<<ans[i].first<<" "<<ans[i].second<<endl;
}
int main(){
int t=;
while(t--) solve();
return ;
}

[CodeForces - 848B] Rooter's Song 思维 找规律的更多相关文章

  1. codeforces 848B Rooter's Song 思维题

    http://codeforces.com/problemset/problem/848/B 给定一个二维坐标系,点从横轴或纵轴垂直于发射的坐标轴射入(0,0)-(w,h)的矩形空间.给出点发射的坐标 ...

  2. Codeforces D. Little Elephant and Interval(思维找规律数位dp)

    题目描述: Little Elephant and Interval time limit per test 2 seconds memory limit per test 256 megabytes ...

  3. Codeforces Gym 100114 A. Hanoi tower 找规律

    A. Hanoi tower Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100114 Descript ...

  4. codeforces Gym 100418D BOPC 打表找规律,求逆元

    BOPCTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/view.action?c ...

  5. Codeforces Round #242 (Div. 2)C(找规律,异或运算)

    一看就是找规律的题.只要熟悉异或的性质,可以秒杀. 为了防止忘记异或的规则,可以把异或理解为半加运算:其运算法则相当于不带进位的二进制加法. 一些性质如下: 交换律: 结合律: 恒等律: 归零律: 典 ...

  6. codeforces Round #440 B Maximum of Maximums of Minimums【思维/找规律】

    B. Maximum of Maximums of Minimums time limit per test 1 second memory limit per test 256 megabytes ...

  7. Codeforces Gym 100015A Another Rock-Paper-Scissors Problem 找规律

    Another Rock-Paper-Scissors Problem 题目连接: http://codeforces.com/gym/100015/attachments Description S ...

  8. Codeforces H. Malek Dance Club(找规律)

    题目描述: Malek Dance Club time limit per test 1 second memory limit per test 256 megabytes input standa ...

  9. The Bits (思维+找规律)

    Description Rudolf is on his way to the castle. Before getting into the castle, the security staff a ...

随机推荐

  1. div内容超出后自动显示滚动条

    一. <div style=" overflow:scroll; width:400px; height:400px;”></div> 记住宽和高一定要设置噢,否则不 ...

  2. MongoDB 及 Mysql 背后的 B/B+树

    索引是数据库常见的数据结构,每个后台开发人员都应该对索引背后的数据结构有所了解. 本文通过分析B-Tree及B-/+Tree数据结构及索引性能分析及磁盘存取原理尝试着回答一下问题: 为什么B-Tree ...

  3. [转载]代码编辑器Sublime Text 3 免费使用方法与简体中文汉化包下载

    http://devework.com/sublime-text-3.html Sublime Text这款代码编辑器是Jeff 一直都在使用的,前段时间转用到版本3,因为感觉Sublime Text ...

  4. HDU 4639 hehe 杭电2013多校联赛第四场1008题

    解题报告:题目的意思是输入一个字符串,并规定,里面的“hehe”可以用"wqnmlgb"来代替,也可以不代替,问输入的这个字符串在经过相关的代替之后可以有多少种不同的形态.先打一个 ...

  5. Treats for the Cows 区间DP POJ 3186

    题目来源:http://poj.org/problem?id=3186 (http://www.fjutacm.com/Problem.jsp?pid=1389) /** 题目意思: 约翰经常给产奶量 ...

  6. 谈谈Linux内核驱动的coding style【转】

    转自:http://www.cnblogs.com/wwang/archive/2011/02/24/1960283.html 最近在向Linux内核提交一些驱动程序,在提交的过程中,发现自己的代码离 ...

  7. 2018 CCPC网络赛

    2018 CCPC网络赛 Buy and Resell 题目描述:有一种物品,在\(n\)个地点的价格为\(a_i\),现在一次经过这\(n\)个地点,在每个地点可以买一个这样的物品,也可以卖出一个物 ...

  8. http请求与传参

    这并不算是文章,暂时只做粗略地记录,以免忘记,因此会显得杂乱无章,随便抓了几个包和对postman截图,日后有空再完善 1.get方式 只有一种方式,那就是在url后面跟参数 2.post方式 1)表 ...

  9. js数组基本操作

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN""http://www.w3.org/TR/xhtm ...

  10. python包/模块路径

    当Python执行import语句时,它会在一些路径中搜索Python模块和扩展模块.可以通过sys.path查看这些路径,比如: >>> import sys >>&g ...