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 ...
随机推荐
- 代码随想录算法训练营Day2|977有序数组的平方 209.长度最小的子数组 59螺旋矩阵Ⅱ(C++)
LeetCode刷题,代码随想录算法训练营Day2 977.有序数组的平方 题目链接 : 977.有序数组的平方 题目思路:关键在于双指针思想的应用 输入:nums = [-4,-1,0,3,10] ...
- node版本问题:Error: error:0308010C:digital envelope routines::unsupported
前言 出现这个错误是因为 node.js V17及以后版本中最近发布的OpenSSL3.0, 而OpenSSL3.0对允许算法和密钥大小增加了严格的限制,可能会对生态系统造成一些影响. 在node.j ...
- 生物信息学 Python 入门之源码安装
编程,作为生物信息学的一个基础性技能,是任何一个生信工程师都无法绕开话题.也许有些人还在纠结 Perl 和 Python 到底应该学习哪一个,但作为目前最火最流行的编程语言 Python 还是非常值得 ...
- Java中打印对象输出的字符串到底是什么?
前言 我们在进行 Java 编程时,经常要打印对象,有的是查看是否拿到了该对象,有的是查看该对象中的数据.打印输出的却是一知半解的字符串,那么这个字符串是怎么来的?代表什么?我们如何打印出对象中的数据 ...
- 【技术积累】Python中的PyTorch库【一】
PyTorch库介绍 PyTorch是一个基于Python的科学计算库,用于构建深度学习神经网络.它主要由两个部分组成:一个是PyTorch Tensor库,提供了类似于NumPy的数组操作,但是支持 ...
- 一分钟学一个 Linux 命令 - tar
前言 大家好,我是 god23bin.今天给大家带来的是 Linux 命令系列,每天只需一分钟,记住一个 Linux 命令不成问题.今天,我们要介绍的是一个常用且强大的命令:tar. 什么是 tar ...
- celery笔记七之周期/定时任务及crontab定义
本文首发于公众号:Hunter后端 原文链接:celery笔记七之周期/定时任务及crontab定义 periodic task,即为周期,或者定时任务,比如说每天晚上零点零分需要运行一遍某个函数,或 ...
- 音视频开发进阶|第四讲:音频自动增益控制 AGC
在之前的文章中,我们已经接触了两个重要的音频前处理模块 – 回声消除 AEC 和噪声抑制 ANS,它们分别解决了 RTC 场景下的回声.噪声问题,极大提升了用户的体验.至此,音频前处理三剑客中,就只剩 ...
- Rust 学习笔记:快速上手篇
Rust 学习笔记:快速上手篇 这篇学习笔记将用于记录本人在快速上手 Rust 编程语言时所记录的学习心得与代码实例.为此,我会在本笔记库项目的Programming/LanguageStudy/目录 ...
- Cilium系列-6-从地址伪装从IPtables切换为eBPF
系列文章 Cilium 系列文章 前言 将 Kubernetes 的 CNI 从其他组件切换为 Cilium, 已经可以有效地提升网络的性能. 但是通过对 Cilium 不同模式的切换/功能的启用, ...