#define HAVE_STRUCT_TIMESPEC
#include<bits/stdc++.h>
using namespace std;
vector<int>po[100007],col[100007];
int main(){
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n,m,k;
cin>>n>>m>>k;
int x=0,y=0;
for(int i=1;i<=k;++i){
cin>>x>>y;
po[x].push_back(y);
col[y].push_back(x);
}
long long sum=0;
int tamp=m;
x=1,y=1;
for(int i=0;i<po[1].size();++i)if(po[x][i]>1)
tamp=min(tamp,po[1][i]-1);
sum=tamp;
int a=0,b=0,c=0,d=0;//a为上边界,b为右边界,c为下边界,d为左边界
a=1;
y=tamp;//y为当前处于哪一列
while(1){
tamp=n-c;//tamp为当前行/列最远能走到的位置
for(int i=0;i<col[y].size();++i)if(col[y][i]>x)
tamp=min(tamp,col[y][i]-1);
if(tamp==x)
break;
sum+=tamp-x;
b=m-y+1;
x=tamp;//x为当前处于哪一行
tamp=d+1;
for(int i=0;i<po[x].size();++i)if(po[x][i]<y)
tamp=max(tamp,po[x][i]+1);
if(tamp==y)
break;
sum+=y-tamp;
c=n-x+1;
y=tamp;
tamp=a+1;
for(int i=0;i<col[y].size();++i)if(col[y][i]<x)
tamp=max(tamp,col[y][i]+1);
if(tamp==x)
break;
sum+=x-tamp;
d=y;
x=tamp;
tamp=m-b;
for(int i=0;i<po[x].size();++i)if(po[x][i]>y)
tamp=min(tamp,po[x][i]-1);
if(tamp==y)
break;
sum+=tamp-y;
a=x;
y=tamp;
}
if(sum==1ll*n*m-1ll*k)
cout<<"Yes";
else
cout<<"No";
return 0;
}

Codeforces Round #593 (Div. 2)D(螺旋形模拟)的更多相关文章

  1. Codeforces Round #368 (Div. 2) B. Bakery (模拟)

    Bakery 题目链接: http://codeforces.com/contest/707/problem/B Description Masha wants to open her own bak ...

  2. Codeforces Round #284 (Div. 2)A B C 模拟 数学

    A. Watching a movie time limit per test 1 second memory limit per test 256 megabytes input standard ...

  3. Codeforces Round #285 (Div. 2) A B C 模拟 stl 拓扑排序

    A. Contest time limit per test 1 second memory limit per test 256 megabytes input standard input out ...

  4. Codeforces Round #549 (Div. 2) F 数形结合 + 凸包(新坑)

    https://codeforces.com/contest/1143/problem/F 题意 有n条形如\(y=x^2+bx+c\)的抛物线,问有多少条抛物线上方没有其他抛物线的交点 题解 \(y ...

  5. Codeforces Round #593 (Div. 2) D. Alice and the Doll

    题目:http://codeforces.com/problemset/problem/1236/D思路:机器人只能按照→↓←↑这个规律移动,所以在当前方向能够前进的最远处即为界限,到达最远处右转,并 ...

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

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

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

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

  8. Codeforces Round #593 (Div. 2)

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

  9. Codeforces Round #249 (Div. 2) C题,模拟画图 ----未解决!

    http://codeforces.com/contest/435/problem/C

随机推荐

  1. Docker Compose 使用示例

    一般步骤 1.定义Dockerfile,方便迁移到任何地方: 2.编写docker-compose.yml文件: 3.运行docker-compose up启动服务 示例 准备工作:提前下载好镜像: ...

  2. .net core 删除主表,同时删除子表

    前提条件: 代码懒加载, 数据库有外键关联 var entity = context.主表.Include(o => o.子表).FirstOrDefault(p => p.Id == i ...

  3. Anaconda"无法定位程序输入点 OPENSSL_sk_new_reserve 于动态链接库Anaconda3\Library\bin\libssl-1_1-x64.dll上"的解决办法

    Anaconda"无法定位程序输入点 OPENSSL_sk_new_reserve 于动态链接库Anaconda3\Library\bin\libssl-1_1-x64.dll上" ...

  4. MyBatis-Spring整合之方式3

    通过注解整合 1.在UserDao同级目录下新建接口UserMapper,内容如下: public interface UserMapper { @Select("select * from ...

  5. uniGUI之文件下载(29)

    1]SendFile 2]SendStream 3]自定义类型文件下载 1]SendFile UniSession.SendFile('新建文本文档.txt' //服务器端 文件名 ,'anew.tx ...

  6. ehcache注解全面解析

    通过ehcache以编程方式使用缓存: 跟上面的方式相同,但是缓存通过ehcache去管理,当然比使用map有N多种好处,比如缓存太大了快达到上限之后,将哪一部分缓存清除出去.这种方式完全是通过代码的 ...

  7. Bugku-CTF加密篇之告诉你个秘密(ISCCCTF)

    告诉你个秘密(ISCCCTF)   636A56355279427363446C4A49454A7154534230526D6843 56445A31614342354E326C4B4946467A5 ...

  8. [Linux kali] linux kali [KDE]一些软件切换输入法无效

    #开始 今天最终是在实体机安装了Kali Kali的默认桌面是GNOME桌面 但是用久了windows桌面用这个实在是不习惯 然后看到了kali有自带KDE版本的 然后就下载了一个尝尝鲜 之前在Deb ...

  9. rsyslog日志服务部署

    rsyslog简介 rsyslog是CentOS6和CentOS7默认的记录日志的服务 支持特性: UDP, TCP, SSL, TLS, RELP MySQL, PGSQL, Oracle实现日志存 ...

  10. LFTP命令笔记

    安装 因为在OpenWrt命令行下scp传输文件很慢(只有2.5MB/s不到), 于是改用FTP下载. lftp是OpenWrt下的FTP客户端软件. 如果固件中未安装的话, 需要自己安装, 其依赖于 ...