UVA10881 Piotr‘s Ants

2023-05-16

#include <iostream>
#include <cstdio>
#include "bits/stdc++.h"
#define ll  long long
using namespace std;

const int maxn = 10000 + 5;

int L,T,n;
struct Ant{
    int id;
    int p; // 位移
    int d; // L -1 R 1
    bool operator < (const Ant & b) const{
        return p < b.p;
    }
}before[maxn],after[maxn];
int order[maxn];
char dir[3][10] = {"L","Turning","R"};

int main(){
    int K;
    cin>>K;
    for(int kase = 0;kase<K;kase++)
    {
        printf("Case #%d:\n",kase+1);
        cin>>L>>T>>n;
        for(int i = 0;i<n;i++)
        {
            int p,d;
            char c;
            cin>>p>>c;
            d = (c == 'L' ? -1 : 1);
            before[i] = (Ant){i,p,d};
            after[i] = (Ant){0,p+T*d,d};
        }

        sort(before,before+n);
        for(int i = 0;i<n;i++)
        {
            order[before[i].id] = i;
        }
        sort(after,after+n);

        for(int i = 0;i<n-1;i++)
        {
            if(after[i].p == after[i+1].p)
            {
                after[i].d = after[i+1].d = 0;
            }
        }

        for(int i = 0;i<n;i++)
        {
            int id = order[i];
            if(after[id].p < 0 || after[id].p > L) printf("Fell off\n");
            else{
                printf("%d %s\n",after[id].p,dir[after[id].d+1]);
            }
        }
        cout<<endl;
    }
    return 0;
}
/**
 *
 *
2
10 1 4
1 R
5 R
3 L
10 R
 10 2 3
 4 R
 5 L
 8 R
 
 */

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

UVA10881 Piotr‘s Ants 的相关文章

随机推荐

  • 用Java实现天天酷跑(附源码),这个真的有点强了!

    点击上方 阿拉奇学Java xff0c 选择 置顶或者星标 每天早晨00点00分 与你相约 xff01 首先 xff0c 写一个需求文档 xff1a 一 项目名称 xff1a 天天酷跑 xff08 RunDay xff09 二 功能介绍 x
  • SpringBoot开源在线考试系统

    推荐一款在线考试系统 xff1b 基于 SpringBoot 43 Mybatis 43 Shiro 43 mysql 43 redis构建的智慧云智能教育平台 架构上使用完全前后端分离 支持多种题型 xff1a 选择题 多选题 判断题 填
  • 微信闪退Bug罪魁祸首竟是二维码引擎,附源代码分析

    建议别尝试 xff1a 转发这个二维码到群里 xff0c 3秒后你会回来骂我 xff08 抖m求骂 xff09 近日 xff0c 网传微信识别上方二维码就会出现闪退BUG xff0c 小编也忍不住尝试了一下 xff0c 果然 xff0c 一
  • java多线程之线程安全(重点,难点)

    由于操作系统中 线程的调度是抢占式执行的 或者说是随机的 这就造成线程调度执行时 线程的执行顺序是不确定的 虽然有一些代码在这种执行顺序不同的情况下也不会运行出错 但是还有一部分代码会因为执行顺序发生改变而受到影响 这就会造成程序出现Bug
  • React-Native: DatePickerIOS设置选择24小时

    原帖 xff1a https github com mmazzarolo react native modal datetime picker DatePickerIOS选择24小时的方法 xff1a How to set 24 hours
  • 使用chatgpt实现微信聊天小程序(秒回复),github开源(附带链接)

    前言 我在前一段时间突发奇想 xff0c 就使用java来调用chatgpt的接口 xff0c 然后写了一个简单小程序 xff0c 也上了热榜第一 xff0c java调用chatgpt接口 xff0c 实现专属于自己的人工智能助手 xff
  • HttpPost 携带参数的请求方式

    一 HTTP请求 Http的几种请求方式对应程序包中的HttpGet HttpHead HttpPost HttpPut HttpDelete HttpTrace and HttpOptions xff0c 这些类均实现了HttpUriRe
  • mysql 根据时间范围查询

    时间格式为 第一种写法 xff1a select from test where create time between 39 2019 03 05 13 04 07 39 and 39 2019 03 08 13 04 07 39 第二种
  • java 根据条件从List中筛选出符合条件的集合

    1 list 你要在里面筛选的对象集合 存放格式例如 list add user1 list add user2 list add user3 2 xff1a tableColumnName xff1a user 里面的属性字段 xff1a
  • Es QueryBuilder 简单查询

    1 matchQuery String name Object text matchQuery 34 filedname 34 34 value 34 匹配单个字段 xff0c 匹配字段名为filedname 值为value的文档 单个匹配
  • Mysql 查询区分大小写的两种方法

    oracle中查询默认是区分大小写的 xff0c 但是在mysql中默认不区分大小写 解决办法 xff1a mysql可以在SQL语句中加入 binary来区分大小写 BINARY不是函数 xff0c 是类型转换运算符 xff0c 它用来强
  • 微信小程序实现登录页面

    wxml文件 xff1a lt view class 61 34 container 34 gt lt view class 61 34 login icon 34 gt lt image class 61 34 login img 34
  • 锂电池充电IC-TP4056电路设计详解

    首先 xff0c 先介绍下TP4056 TP4056是一款完整的单节锂离子电池采用恒定电流 恒定电压线性充电器 其底部带有散热片的SOP8封装与较少的外部元件数目使得TP4056成为便携式应用的理想选择 TP4056可以适合USB电源和适配
  • mysql无法插入中文的解决办法:修改数据库编码为utf-8

    mysql无法插入中文的解决办法 1 无法插入中文原因 mysql数据库的默认编码是latin1 xff0c 可以使用下面代码查看数据库编码 show variables like 34 character 34 发现有两处的编码是lati
  • 为Debian 10.2 安装图形化桌面环境

    首先先下载x window的内核 xff1a apt get u install x window system core 下载登录管理界面gdm或kdm xff1a apt get u install gdm gdm themes 下载G
  • C# System.BadImageFormatException 解决方法

    出现System BadImageFormatException 异常有两种情况 xff1a 程序目标平台不一致 amp 引用dll文件的系统平台不一致 异常参考 xff1a BadImageFormatException 程序目标平台不一
  • leetcode452

    题目 xff1a 在二维空间中有许多球形的气球 对于每个气球 xff0c 提供的输入是水平方向上 xff0c 气球直径的开始和结束坐标 由于它是水平的 xff0c 所以y坐标并不重要 xff0c 因此只要知道开始和结束的x坐标就足够了 开始
  • UVA-11300

    span class token macro property span class token directive hash span span class token directive keyword include span spa
  • UVA-11520 Fill the Square

    思路 xff1a 因为要求是字典序 xff0c 这道题的第一反应就是从A Z选取字母 xff0c 在正方形中从上到下 xff0c 从左到右这样的顺序去填字母 xff0c 一旦判断这个字母旁边没有和它一样的 xff0c 那么就证明这个字母就是
  • UVA10881 Piotr‘s Ants

    span class token macro property span class token directive hash span span class token directive keyword include span spa