#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. 力扣MYSQL练习

    176编写一个 SQL 查询,获取 Employee 表中第二高的薪水(Salary) . select IFNULL((SELECT distinct salary from employee or ...

  2. Tinyhttp源码分析

    简介 Tinyhttp是一个轻量型Http Server,使用C语言开发,全部代码只500多行,还包括一个简单Client. Tinyhttp程序的逻辑为:一个无线循环,一个请求,创建一个线程,之后线 ...

  3. mysql 随笔

    (select GROUP_CONCAT(car_brand_name separator ',') carBrandName,supplier_id from ycej_supplier_carbr ...

  4. 3.CRUD(增删改查)

    Select 选择,查询语句 id:就是对应的namespace中的方法名: resultType:Sql语句执行的返回值: parameterType:参数类型 我们想使用查询语句首先要在UserM ...

  5. Android学习15

    Date&Time DatePicker(日期选择器),TimePicker(时间选择器),CalendarView(日期视图): 1.TextClock TextClock可以以字符串格式显 ...

  6. PHP通过thrift2访问HBASE

    前一段时间需要在网页上显示HBASE查询的结果,考虑用PHP来实现,在网上搜了一下,普遍都是用thrift作为接口来实现的.​ 参考博文:​ http://www.cnblogs.com/scotom ...

  7. C语言中二维数组如何申请动态分配内存

    C语言中二维数组如何申请动态分配内存: 使用malloc函数,先分配第一维的大小,然后再循环分配每一维的大小 #include <stdio.h> #include <malloc. ...

  8. 基于Aspectj表达式配置的Spring AOP

    AOP(Aspect-Oriented Programming, 面向切面编程):是一种新的方法论, 是对传统OOP(Object-Oriented Programming, 面向对象编程)的补充. ...

  9. 03hive_DDL数据定义

    一. DDL数据定义 创建数据库 1)create database db_hive; 2)避免要创建的数据库已经存在错误,增加 if not exists 判断. create database i ...

  10. Django框架之Filters(过滤器)、母版的使用

    在Django的模板语言中,通过使用 过滤器 来改变变量的显示. 过滤器的语法: {{ value|filter_name:参数 }} 使用管道符"|"来应用过滤器. 注意事项: ...