Codeforces Round #593 (Div. 2) D. Alice and the Doll
题目:http://codeforces.com/problemset/problem/1236/D
思路:机器人只能按照→↓←↑这个规律移动,所以在当前方向能够前进的最远处即为界限,到达最远处右转,并且下次在该方向无法再移动到更远的地方,因此按照→↓←↑模拟即可,每次移动更新界限 ,无法移动则结束(第一次无法移动可右转,n*m会爆int)
障碍用set存,每次二分寻找能到达最远的地方,并与界限比较
#include<bits/stdc++.h> using namespace std; #define pb push_back #define fi first #define se second #define mem(i,j) memset(i,j,sizeof(i)) typedef long long ll; typedef pair<int,int>pii; ; ll n,m; int k; int a,b; set<int>x[maxn],y[maxn]; int main() { scanf("%I64d%I64d%d",&n,&m,&k); ;i<=k;i++) { scanf("%d%d",&a,&b); x[a].insert(b); y[b].insert(a); } ; ,yy=; ll cnt=; int t; ,maxx=n,miny=,maxy=m; ) { ) { t=yy; auto it=x[xx].lower_bound(yy); if(it==x[xx].end()) yy=m; ; if(yy>maxy) yy=maxy; maxy=yy-; &&xx!=&&yy!=) break; cnt+=yy-t; } ) { t=xx; auto it=y[yy].lower_bound(xx); if(it==y[yy].end()) xx=n; ; if(xx>maxx) xx=maxx; maxx=xx-; ) break; cnt+=xx-t; } ) { t=yy; auto it=x[xx].lower_bound(yy); ; ; if(yy<miny) yy=miny; miny=yy+; ) break; cnt+=t-yy; } ) { t=xx; auto it=y[yy].lower_bound(xx); ; ; if(xx<minx) xx=minx; minx=xx+; ) break; cnt+=t-xx; } ;} turn=(turn+)%; } printf("No\n"); ; }
Codeforces Round #593 (Div. 2) D. Alice and the Doll的更多相关文章
- Codeforces Round #593 (Div. 2)
传送门 A. Stones 签到. B. Alice and the List of Presents 单独考虑每个数的贡献即可. 答案为\((2^{m}-1)^n\). C. Labs 构造就类似于 ...
- Codeforces Round #201 (Div. 2) - C. Alice and Bob
题目链接:http://codeforces.com/contest/347/problem/C 题意是给你一个数n,然后n个数,这些数互不相同.每次可以取两个数x和y,然后可以得到|x - y|这个 ...
- Codeforces Round #593 (Div. 2) C. Labs A. Stones
题目:https://codeforces.com/contest/1236/problem/A 思路:两种操作收益都是3 且都会消耗b 操作2对b消耗较小 则可优先选择操作2 再进行操作1 即可得到 ...
- Codeforces Round #593 (Div. 2) C. Labs
题目:https://codeforces.com/contest/1236/problem/C 思路:将 n ^ 2 个 lab 平分为 n 个 group group A 和 B 组成的 有序对 ...
- Codeforces Round #593 (Div. 2)D(螺旋形模拟)
#define HAVE_STRUCT_TIMESPEC#include<bits/stdc++.h>using namespace std;vector<int>po[100 ...
- Codeforces Round #557 (Div. 1) 简要题解
Codeforces Round #557 (Div. 1) 简要题解 codeforces A. Hide and Seek 枚举起始位置\(a\),如果\(a\)未在序列中出现,则对答案有\(2\ ...
- Codeforces Round #721 (Div. 2)A. And Then There Were K(位运算,二进制) B1. Palindrome Game (easy version)(博弈论)
半个月没看cf 手生了很多(手动大哭) Problem - A - Codeforces 题意 给定数字n, 求出最大数字k, 使得 n & (n−1) & (n−2) & ...
- Codeforces Round #366 (Div. 2) ABC
Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate ...
- Codeforces Round #354 (Div. 2) ABCD
Codeforces Round #354 (Div. 2) Problems # Name A Nicholas and Permutation standard input/out ...
随机推荐
- JavaScript高程第三版笔记-面向对象编程
之前有篇博客曾提到过一点js的面向对象编程:js面向对象编程. 这里就结合js高程详细剖析一下javascript的面向对象编程. 前序: 1⃣️Object.defineProperty() var ...
- vscode 中sftp配置
简单记录一下,相对路径的设置不用“/”表明根目录等,直接写目录名字即可 { "name": "profile name", "prot ...
- Day03:日期操作 / 集合框架(上)
日期操作 Java中的时间 · Java中的时间使用标准类库的Date类表示,是用距离一个固定时间点的毫秒数(可正可负,long类型)表达一个特定的时间点: · 固定的时间点叫纪元(epoch),是U ...
- 转-Uptime与数据中心等级认证
1 数据中心等级认证 随着数据中心的蓬勃发展,越来越多的标准被制定出具.其中,Uptime Tier认证在业内是认同度最高的标准.以前,Uptime在中国的宣传很少,很多人对Uptime及其认证体系不 ...
- Linux批量文件管理
Linux批量文件管理 实验目标: 通过本实验掌握批量建立.移动.复制文件或目录的操作,也可以作为后续shell编程的基础. 实验步骤: 1.现在有十台终端机器,要为每台机器建立3个文件,总共要建 ...
- 【并行计算】Windows系统下搭建MPI环境
Windows系统下搭建MPI环境 MPI的全称是Message Passing Interface即标准消息传递界面,可以用于并行计算.MPI的具体实现一般采用MPICH.下面介绍如何在Window ...
- springboot 极简使用例子: redis,MySql数据库,日志,netty,打包和运行
配置 创建项目的时候选择 application.yml内容如下 spring: redis: host: 127.0.0.1 port: 6379 database: 0 datasource: d ...
- splite与join
Python split() 通过指定分隔符对字符串进行切片 切片之后为list数据类型. sentence = 'I can because I think I can ' s_1 = senten ...
- sql server2012中使用convert来取得datetime数据类型样式(全)
一.日期数据格式的处理,两个示例: CONVERT(varchar(16), 时间一, 20) 结果:2007-02-01 08:02/*时间一般为getdate()函数或数据表里的字段*/ CONV ...
- C#控制台输入/输出语句
Console.Read()方法: 从控制台窗口读取一个字符,返回int值 Console.ReadLine()方法: 从控制台窗口读取一行文本,返回string值 Conso ...