Vika and Her Friends
Smiling & Weeping
----早知道思念那么浓烈,不分手就好了
题目大意:有n个Vika的朋友在一个n*m的方格中去捉Vika,给出Vika和她朋友的初始位置(坐标),求出Vika能否逃出朋友的追捕。
思路:怎么说╮(╯▽╰)╭ 你知道这个逻辑你就能把题目做出来,不知道这个逻辑你就做不出来,现在上逻辑
- 小v和朋友在同一行,如果小v向朋友靠近,朋友也向小v靠近,距离减小;如果小v沿行远离朋友的方向前进,朋友继续跟上,距离减小;如果小v沿列方向行走,朋友继续沿靠近朋友行的方向前进。
- 小v和朋友在同一列,如果小v像朋友靠近,朋友也向小v靠近,距离减小;如果小v沿列远离朋友的方向前进,朋友继续跟上,距离减小;如果小v沿行方向行走,朋友继续沿靠近朋友列的方向前进。
- 小v和朋友在不同行不同列,如果小v沿行(列)方向接近朋友,朋友沿列(行)的方向朝小v前进。如果小v沿行(列)的方向远离朋友,朋友沿行(列)的方向前进,距离减少。
逻辑大概就是这样:
- If Vika is in the same column as the friend. If Vika goes towards the friend, then the friend goes towards her, reducing the distance. If Vika goes in the opposite direction, then the friend also goes towards her, reducing the area to Vika. If Vika goes along the row, then the friend goes towards Vika along the column, which also reduces the area to Vika.
- If Vika is in the same row as the friend. If Vika goes towards the friend, then the friend goes towards her, reducing the distance. If Vika goes in the opposite direction, then the friend also goes towards her, reducing the area to Vika. If Vika goes along the column, then the friend goes towards Vika along the row, which also reduces the area to Vika.
- If Vika and the friend are in different rows and columns. If Vika goes towards the friend along the row, then the friend goes towards her along the column, reducing the distance. If Vika goes towards the friend along the column, then the friend goes towards her along the row, reducing the distance. If Vika goes away from the friend, then the friend makes a move in the same direction, thereby reducing the area to Vika.
Talk is cheap , show me the code
1 #include<bits/stdc++.h>
2 using namespace std;
3 int t , n;
4 int main()
5 {
6 scanf("%d",&t);
7 while(t--)
8 {
9 int a,b;
10 scanf("%d%d%d",&a,&b,&n);
11 int x,y,xx,yy;
12 bool flag = false;
13 scanf("%d%d",&x,&y);
14 for(int i = 1; i <= n; i++)
15 {
16 scanf("%d%d",&xx,&yy);
17 if((x+y)%2 == (xx+yy)%2) flag = true;
18 }
19 if(flag)
20 printf("NO\n");
21 else
22 printf("YES\n");
23 }
24 return 0;
25 }
文章到此结束,愿我们此去行止由心
Vika and Her Friends的更多相关文章
- Codeforces Round #337 (Div. 2) D. Vika and Segments 线段树 矩阵面积并
D. Vika and Segments Vika has an infinite sheet of squared paper. Initially all squares are whit ...
- Codeforces Round #337 Vika and Segments
D. Vika and Segments time limit per test: 2 seconds memory limit per test: 256 megabytes input ...
- Codeforces Round #337 (Div. 2) B. Vika and Squares 水题
B. Vika and Squares Vika has n jars with paints of distinct colors. All the jars are numbered from ...
- Codeforces Round #337 (Div. 2) D. Vika and Segments 线段树扫描线
D. Vika and Segments 题目连接: http://www.codeforces.com/contest/610/problem/D Description Vika has an i ...
- Codeforces Round #337 (Div. 2) B. Vika and Squares 贪心
B. Vika and Squares 题目连接: http://www.codeforces.com/contest/610/problem/B Description Vika has n jar ...
- Codeforces Round #337 (Div. 2) B. Vika and Squares
B. Vika and Squares time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- Vika and Segments - CF610D
Vika has an infinite sheet of squared paper. Initially all squares are white. She introduced a two-d ...
- codeforces 610D D. Vika and Segments(离散化+线段树+扫描线算法)
题目链接: D. Vika and Segments time limit per test 2 seconds memory limit per test 256 megabytes input s ...
- Codeforces Round #337 (Div. 2) 610B Vika and Squares(脑洞)
B. Vika and Squares time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- 【20.51%】【codeforces 610D】Vika and Segments
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
随机推荐
- linux 的 vi 命令详解
vi编辑器是所有Unix及Linux系统下标准的编辑器,它的强大不逊色于任何最新的文本编辑器,这里只是简单地介绍一下它的用法和一小部分指令.由于对Unix及Linux系统的任何版本,vi编辑器是完全相 ...
- GIT多场景下使用
git对于大家应该都不太陌生,熟练使用git已经成为程序员的一项基本技能,尽管在工作中有诸如 Sourcetree这样牛X的客户端工具,使得合并代码变的很方便.但找工作面试和一些需彰显个人实力的场景, ...
- Galaxy生物信息分析平台的数据集对象清理
由于微信不允许外部链接,你需要点击文章尾部左下角的 "阅读原文",才能访问文中链接. Galaxy Project 是在云计算背景下诞生的一个生物信息学可视化分析开源项目.该项目由 ...
- Java基础之基础语法与面向对象
前言 小知识 Java由Sun公司于1995年推出,2009年Sun公司被Oracle公司收购,取得Java的版权 Java之父:James Gosling(詹姆斯·高斯林) 专业术语 JDK:jav ...
- 云原生时代Go最受欢迎Web开源框架Gin原理与实战
@ 目录 概述 定义 特点 概览导图 使用 快速入门 HTTP 方法使用 参数获取 参数绑定 自定义日志输出 自定义中间件 路由组 HTML渲染 设置和获取Cookie XML.YAML.ProtoB ...
- 前端Vue自定义顶部搜索框 热门搜索 历史搜索 用于搜索跳转使用
前端Vue自定义顶部搜索框 热门搜索 历史搜索 用于搜索跳转使用, 下载完整代码请访问uni-app插件市场地址:https://ext.dcloud.net.cn/plugin?id=13128 效 ...
- 3D降噪_时域降噪待补充
视频去噪方法按照处理域的不同可分为空间域.频域.小波域.时域.时-空域去噪等,但是不同域之间的去噪方法会发生重叠现象,或者一种去噪方法会或涉及多个处理域.例如,在时域或时-空域去噪方法中也可使用频域的 ...
- 云储存选择做Hexo博客图床(腾讯云、七牛云、网易云)
前言 博客里需要添加很多图片作为内容的补充,但是把图片放在本地博客文件夹里,上传到网上后,加载这些图片就是一个很大的问题,他们会拖累网页加载的速度,所以建议把图片放图床里,通过外链来访问和加载这些图片 ...
- 开发自己的Prometheus Exporter、实现自定义指标
Prometheus Exporter基础知识 Prometheus Exporter的概念.工作原理 Prometheus Exporter是一个用来收集和暴露指标数据的工具,通过与Prometh ...
- 基于Avalonia 11.0.0+ReactiveUI 的跨平台项目开发2-功能开发
基于Avalonia 11.0.0+ReactiveUI 的跨平台项目开发2-功能开发 项目简介:目标是开发一个跨平台的AI聊天和其他功能的客户端平台.目的来学习和了解Avalonia.将这个项目部署 ...