题目: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的更多相关文章

  1. Codeforces Round #593 (Div. 2)

    传送门 A. Stones 签到. B. Alice and the List of Presents 单独考虑每个数的贡献即可. 答案为\((2^{m}-1)^n\). C. Labs 构造就类似于 ...

  2. Codeforces Round #201 (Div. 2) - C. Alice and Bob

    题目链接:http://codeforces.com/contest/347/problem/C 题意是给你一个数n,然后n个数,这些数互不相同.每次可以取两个数x和y,然后可以得到|x - y|这个 ...

  3. Codeforces Round #593 (Div. 2) C. Labs A. Stones

    题目:https://codeforces.com/contest/1236/problem/A 思路:两种操作收益都是3 且都会消耗b 操作2对b消耗较小 则可优先选择操作2 再进行操作1 即可得到 ...

  4. Codeforces Round #593 (Div. 2) C. Labs

    题目:https://codeforces.com/contest/1236/problem/C 思路:将 n ^ 2 个 lab 平分为 n 个 group group A 和 B 组成的 有序对 ...

  5. Codeforces Round #593 (Div. 2)D(螺旋形模拟)

    #define HAVE_STRUCT_TIMESPEC#include<bits/stdc++.h>using namespace std;vector<int>po[100 ...

  6. Codeforces Round #557 (Div. 1) 简要题解

    Codeforces Round #557 (Div. 1) 简要题解 codeforces A. Hide and Seek 枚举起始位置\(a\),如果\(a\)未在序列中出现,则对答案有\(2\ ...

  7. 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) & ...

  8. 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 ...

  9. Codeforces Round #354 (Div. 2) ABCD

    Codeforces Round #354 (Div. 2) Problems     # Name     A Nicholas and Permutation standard input/out ...

随机推荐

  1. Python:Base2(List和Tuple类型, 条件判断和循环,Dict和Set类型)

    1.Python创建list: Python内置的一种数据类型是列表:list.list是一种有序的集合,可以随时添加和删除其中的元素. 比如,列出班里所有同学的名字,就可以用一个list表示: &g ...

  2. C#吾日三省吾身

    全局变量与局部变量区别: 全局变量声明完毕后,就算不手动初始化赋值,也是有默认值的; 但是局部变量声明完毕后,如果不给它手动赋值,是无法直接使用这个变量的. 尽量避免少的装箱拆箱: ; .ToStri ...

  3. Linux常用目录名称

    目录 用途 / 虚拟目录的根文件,通常不会在这里存储文件 /bin 二进制目录,存放许多用户的GNU工具 /boot 启动目录,存放启动文件 /dev 设备目录,Linux在这里创建设备节点 /etc ...

  4. netcore程序部署 ubuntu 16.0.4 报错 The type initializer for 'System.Net.Http.CurlHandler'的解决方案

    最近业务扩展需要把netcore程序部署到ubuntu 16.0.4上,因为代码里面用到了HttpClient 请求. 部署ubuntu后一直报错 参考地址:https://github.com/do ...

  5. 【并行计算】Windows系统下搭建MPI环境

    Windows系统下搭建MPI环境 MPI的全称是Message Passing Interface即标准消息传递界面,可以用于并行计算.MPI的具体实现一般采用MPICH.下面介绍如何在Window ...

  6. 通达信金融终端_尘缘整合_V7.12

    http://pan.baidu.com/s/1gvtPO http://pan.baidu.com/s/1xqrk6 通达信金融终端_尘缘整合_V7.12

  7. 编译安装php7.3

    ./configure --prefix=/usr/local/php7.3.9 --with-gd --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo ...

  8. MySql在win10上的安装(压缩版)

    一.下载: 二.下载zip版,免安装版的. 三.解压缩后,注意:文件夹名称不能包含[空格] C:\MySQL 四.增加环境变量 五.手动在安装目录  C:\MySQL 下新建一个my.ini写入以下内 ...

  9. # 江西CCPC省赛-Rng(概率+逆元)

    江西CCPC省赛-Rng(概率+逆元) 题意: 给出一个n,在[1,n]之间选一个R1,在[1,R1]之间选一个L1,得到区间[L1,R1],同理获取区间[L2,R2],问两个区间相交的概率对1e9+ ...

  10. # Tallest Cows(差分)

    Tallest Cows(差分) n头牛,给出最高牛的位置和身高,其他牛身高未知,给出m对相对关系,表示可以相互看见当且仅当他们中间的牛都比他们矮.求每头牛身高最大值是多少. 差分数组的性质:前缀和为 ...