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 ...
随机推荐
- ES6迭代器(Iterator)和生成器(Generator)
平时我们迭代数据用得最多的应该就是for循环了 来看个简单的例子 var colors = ["red", "green", "blue"] ...
- MAC 打开.bash_profile
1.开启终端(terminal)[左下角启动台(图标)> 其他] 2.进入当前用户目录 $ cd ~ 3.打开profile文件 $ open -e .bash_profile 就会弹出.bas ...
- 自定义组件模拟v-model
在项目中常常会遇到一个组件中引入好几个子组件的情况,而引入的子组件和子组件之间又需要有数据交互,如果使用父组件作为桥梁进行数据交互这个也是可以的,只是有些麻烦,so最理想的是子组件和子组件自己去交互, ...
- K8S | 核心原理分析
目录 一.背景 二.持续集成 三.K8S架构 1.核心组件 2.分层结构 3.核心能力 3.1 发现与负载 3.2 调度 3.3 自动伸缩 四.应用案例 1.服务部署 2.交互流程 五.参考源码 整体 ...
- 【了解LLM】—— LLM&& SD 基本概念
本文地址:https://www.cnblogs.com/wanger-sjtu/p/17417312.html Causual LM 这里以llama模型为例,通常在执行用户输入之前会有一个[[文章 ...
- 如何从AWS中学习如何使用AmazonVPC
目录 如何从 AWS 中学习如何使用 Amazon VPC? 随着 AWS 的迅速发展,Amazon VPC(Virtual Private Cloud)已经成为了一种非常重要的云计算基础设施.VPC ...
- Mysql基础篇(四)之事务
一. 事务简介 事务是一组操作的集合,它是一个不可分隔的工作单位,事务会把所有的操作作为一个整体一起向系统提交或撤销操作请求,即这些操作要么同时成功,要么同时失败. 就比如:张三给李四转账1000块钱 ...
- LSP协议被劫持,导致无法上网
QQ无法登录,网页打不开 用火绒的断网修复 说已经修复了 结果屁用没有 然后找的百度经验 管理员打开命令行窗口 输入 netsh winsock reset catalog 重启即生效
- SaaS软件工程师成长路径
背景 SaaS软件工程师的成长需要循序渐进,和SaaS业务一样有耐心.SaaS工程师需要在"业务"."技术"."管理"三个维度做好知识储备. ...
- Redis核心技术与实践 01 | 基本架构:一个键值数据库包含什么?
原文地址:https://time.geekbang.org/column/article/268262 个人博客地址:http://njpkhuan.cn/archives/redis-he-xin ...