大致题意:

      有一个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. 在IDEA中实战Git 实用

    工作中多人使用版本控制软件协作开发,常见的应用场景归纳如下: 假设小组中有两个人,组长小张,组员小袁 场景一:小张创建项目并提交到远程Git仓库 场景二:小袁从远程Git仓库上获取项目源码 场景三:小 ...

  2. android 水波纹效果实现

    1.在drawable文件下,新建seletor,作为button的背景,这里我用的是两个圆角的shape <?xml version="1.0" encoding=&quo ...

  3. 20145234黄斐《Java程序设计》第七周

    教材学习内容总结 第十二章部分 - Lambda 认识Lambda语法 Lambda去可以重复,符合DRY原则,而且Lambda表达式可读性更好,操作更简单 匿名类型最大的问题就在于其冗余的语法,la ...

  4. java基础学习:JavaWeb之Cookie和Session

    一.会话概述 1.1.什么是会话? 会话可简单理解为:用户开一个浏览器,点击多个超链接,访问服务器多个web资源,然后关闭浏览器,整个过程称之为一个会话其中不管浏览器发送多少请求,都视为一次会话,直到 ...

  5. python正则表达式-re模块的爱恨情仇

    利用python的re模块,使用正则表达式对字符串进行处理 # 编辑者:闫龙 import re restr = "abccgccc123def456ghi789jgkl186000&quo ...

  6. 查看 CUDA cudnn 版本

    cuda 版本 cat /usr/local/cuda/version.txt cudnn 版本 cat /usr/local/cuda/include/cudnn.h | grep CUDNN_MA ...

  7. 防止 Google Smart Lock 记忆错的用户名

    默认 chrome 会查找密码上面的那个(非隐藏非禁用)的表单域 如果上面是个短信验证码框,就会将验证码当成用户名提示用户保存. 在用户名 input 上添加 autocomplete="u ...

  8. Multiple HTTPS Bindings IIS 7 Using appcmd

    http://toastergremlin.com/?p=308 Sometimes when using a wildcard SSL or Unified Communications Certi ...

  9. redis安装(linux)

    一.redis安装步骤 1.yum install gcc  如果你机器已经安装了编译环境请忽略,否则在使用make编译源码时会报错. 报错信息:make: *** [adlist.o]  2.使用w ...

  10. python字典解析

    import json # coding: utf-8 from functools import singledispatch from collections import abc import ...