Codeforces Round #593 (Div. 2)D(螺旋形模拟)
#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(螺旋形模拟)的更多相关文章
- Codeforces Round #368 (Div. 2) B. Bakery (模拟)
Bakery 题目链接: http://codeforces.com/contest/707/problem/B Description Masha wants to open her own bak ...
- 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 ...
- 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 ...
- Codeforces Round #549 (Div. 2) F 数形结合 + 凸包(新坑)
https://codeforces.com/contest/1143/problem/F 题意 有n条形如\(y=x^2+bx+c\)的抛物线,问有多少条抛物线上方没有其他抛物线的交点 题解 \(y ...
- Codeforces Round #593 (Div. 2) D. Alice and the Doll
题目:http://codeforces.com/problemset/problem/1236/D思路:机器人只能按照→↓←↑这个规律移动,所以在当前方向能够前进的最远处即为界限,到达最远处右转,并 ...
- 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)
传送门 A. Stones 签到. B. Alice and the List of Presents 单独考虑每个数的贡献即可. 答案为\((2^{m}-1)^n\). C. Labs 构造就类似于 ...
- Codeforces Round #249 (Div. 2) C题,模拟画图 ----未解决!
http://codeforces.com/contest/435/problem/C
随机推荐
- 【SSH】Spring 整合 Struts
添加 spring-struts-3.2.9.RELEASE.jar struts-config.xml 添加 <controller> <set-property property ...
- GIT-maven
maven 一:什么是maven 1.maven是基于项目对象模型(POM),可以通过一小段描述信息来管理项目的创建,报告和文档的软件项目管理工具. 2.maven是跨平台的项目管理工具,主要服务于 ...
- Spring Boot整合EhCache
本文讲解Spring Boot与EhCache的整合. 1 EhCache简介 EhCache 是一个纯Java的进程内缓存框架,具有快速.精干等特点,是Hibernate中默认CacheProvid ...
- selenium 使用close和quit关闭driver的不同点
Driver.Quit()与Driver.Close()的不同:Driver.Quit(): Quit this dirver, closing every associated windows;Dr ...
- Java_Habse_add
import java.io.IOException; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hb ...
- Spring Boot框架 - application.properties配置
阅读此文章之前,需要参考 https://www.cnblogs.com/mysummary/p/12238242.html 创建Spring Boot项目 建成后目录如下 一.在com.demo.s ...
- The Preliminary Contest for ICPC Asia Xuzhou 2019 G Colorful String(回文自动机+dfs)
这题建立一棵回文树,然后用dfs搜索答案,但是有一点需要注意,就是打vis的标记时,如果标记为1,那么在好几个节点都对同一个字符i打过标记,此时的搜索从字符i点回溯,回到它的父亲节点,搜索其它的字符, ...
- Linux下载安装
博客及下载 https://www.cnblogs.com/nongzihong/p/10475753.html centos镜像 下载 https://blog.csdn.net/sinat_365 ...
- CapsNet资源
算法源码: https://github.com/xanderchf/pyCapsNet https://github.com/naturomics/CapsNet-Tensorflow 参考文章: ...
- Vue项目中sass语法该怎么用?
最近开始着手Vue框架,被各种报错蹂躏,其中有一个就是sass语法,<style>标签中添加<style lang="scss">,发现报错,在网上找了一些 ...