大致题意:

      有一个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. Java并发编程原理与实战二十二:Condition的使用

    Condition的使用 Condition用于实现条件锁,可以唤醒指定的阻塞线程.下面来实现一个多线程顺序打印a,b,c的例子. 先来看用wait和notify的实现: public class D ...

  2. MapReduce (hive表SequenceFile的结果做输入)、MultipleOutputs和Reduce端迭代iterable的一些说明

    很长时间以来一直写hive,嵌套脚本.偶尔写UDF.  最近用Hive的dynamic partition和多路插入做一些事情,很遗憾的结果是非常不稳定,有时能成功,有时失败.(可能是因为hive版本 ...

  3. 对 jQuery 中 data 方法的误解

    一直以来都认为新版本中 data 是调用 dataset 实现的,对于低版本IE则采用 getAttribute其实一直是我误解了,也不知道最初这个想法是怎么来的.难道我被盗梦了? 今天 谢亮 兄弟和 ...

  4. 出了一个js的题。

    class test { set xx(v){ console.log('i am set'); this.__ok = v; } get xx(){ console.log('i am get'); ...

  5. Xilinx Altera FPGA中的逻辑资源(Slices VS LE)比较

    前言 经常有朋友会问我,“我这个方案是用A家的FPGA还是X家的FPGA呢?他们的容量够不够呢?他们的容量怎么比较呢?”当然,在大部分时候,我在给客户做设计的时候,直接会用到最高容量的产品,因为我们的 ...

  6. 针对用户在个人中心绑定手机认证的一些js代码。

    需求: 1:手机号码校验(格式的校验,手机号码是否已经绑定过)---未实现 2:填完手机号码,点击发送验证码,手机会收到一条信息 3:发送验证码按钮不可用,变成重新发送的倒计时 1):60秒以后又可以 ...

  7. jquery ajax complete 方法

    jquery ajax var ajaxTimeoutTest = $.ajax({ url:'',  //请求的URL timeout : 1000, //超时时间设置,单位毫秒 type : 'g ...

  8. nginx+tomat https ssl 部署 完美解决方案

    关于nginx+tomcat https的部署之前网上一直有2种说法: 1.nginx和tomcat都要部署ssl证书 2.nginx部署ssl证书,tomcat增加ssl支持 在实际的部署过程中ng ...

  9. Dream------Hadoop--Hadoop HA QJM (Quorum Journal Manager)

    In a typical HA cluster, two separate machines are configured as NameNodes. At any point in time, ex ...

  10. Word Ladder I & II

    Word Ladder I Given two words (start and end), and a dictionary, find the length of shortest transfo ...