Smiling & Weeping

                ----早知道思念那么浓烈,不分手就好了

题目链接:Problem - A - Codeforces

题目大意:有n个Vika的朋友在一个n*m的方格中去捉Vika,给出Vika和她朋友的初始位置(坐标),求出Vika能否逃出朋友的追捕。

思路:怎么说╮(╯▽╰)╭ 你知道这个逻辑你就能把题目做出来,不知道这个逻辑你就做不出来,现在上逻辑

  1. 小v和朋友在同一行,如果小v向朋友靠近,朋友也向小v靠近,距离减小;如果小v沿行远离朋友的方向前进,朋友继续跟上,距离减小;如果小v沿列方向行走,朋友继续沿靠近朋友行的方向前进。
  2. 小v和朋友在同一列,如果小v像朋友靠近,朋友也向小v靠近,距离减小;如果小v沿列远离朋友的方向前进,朋友继续跟上,距离减小;如果小v沿行方向行走,朋友继续沿靠近朋友列的方向前进。
  3. 小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的更多相关文章

  1. 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 ...

  2. Codeforces Round #337 Vika and Segments

    D. Vika and Segments time limit per test:  2 seconds     memory limit per test:  256 megabytes input ...

  3. 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 ...

  4. 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 ...

  5. 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 ...

  6. 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 ...

  7. Vika and Segments - CF610D

    Vika has an infinite sheet of squared paper. Initially all squares are white. She introduced a two-d ...

  8. codeforces 610D D. Vika and Segments(离散化+线段树+扫描线算法)

    题目链接: D. Vika and Segments time limit per test 2 seconds memory limit per test 256 megabytes input s ...

  9. 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 ...

  10. 【20.51%】【codeforces 610D】Vika and Segments

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

随机推荐

  1. Python基础 - 注释

    单行注释 Python中使用#表示单行注释.一般在#后面添加一个空格,再添加注释内容 1 # 这是单行注释 多行注释   Python中使用三个单引号或三个双引号表示多行注释. 1 ''' 2 这是使 ...

  2. 人工智能导论——口罩佩戴检测详解(附带MTCNN论文精读)

    人工智能导论--口罩佩戴检测详解(附带MTCNN论文精读) 一.问题重述 随着人类的科技不断进步,病毒也在随之更新迭代:在19年席卷全球的新冠肺炎疫情给人们的生活带来了极大的灾难,造成了无数的人因此失 ...

  3. GaussDB(DWS)迁移实践丨row_number输出结果不一致

    摘要:迁移前后结果集row_number字段值前后不一致,前在DWS上运行不一致. 本文分享自华为云社区<GaussDB(DWS)迁移 - oracle兼容 --row_number输出结果不一 ...

  4. Windows 安装ActiveMq5.16.6

    Windows 安装ActiveMq5.16.6 前言 最近因为需要在项目中使用MQ,所以就想在我的老Windows机器上装个ActiveMq. 1. 下载安装 先到Activemq官网下载安装需要版 ...

  5. Jackson前后端开发模式必备json利器

    前言 json是我们现代互联网程序最常用的交互格式,是否你在工作中会遇到前端说字段不一致需要改的需求,是否遇到过数据库字段名与javaBean的规范不同,是否遇到过json与javaBean相互转换时 ...

  6. NixOS 与 Nix Flakes 新手入门

    独立博客阅读: https://thiscute.world/posts/nixos-and-flake-basics/ 长文警告️ 本文的目标 NixOS 版本为 22.11,Nix 版本为 2.1 ...

  7. 【Netty实战】1~3章学习笔记

    1. Netty总体结构 1.1 Netty简介 ​ Netty是一款用于创建高性能网络应用程序的高级框架.它的基于 Java NIO 的异步的和事件驱动的实现,保证了高负载下应用程序性能的最大化和可 ...

  8. Electron App 安装包定制 -- Inno Setup 脚本 Pascal Scripting 初探

    在做 Electron 项目时,有个需求是安装包安装时要给客户机上装上某个软件 在查看 Inno Setup 官网后发现是通过 .iss 脚本编写实现自定义安装过程 可在 .iss 内可以添加脚本为安 ...

  9. 大批量插入数据(sql insert)

    1.批量录入(方法一:mybiats foreach标签) 所述的MySQL和Oracle的批量插入区别可以看出可能有兼容性问题(使用Oracle 的同学重点参考下) 而且jdbc链接Url要加上 a ...

  10. Kubernetes(k8s) 资源限制:resources,LimitRange,ResourceQuota

    目录 一.系统环境 二.前言 三.Kubernetes资源限制简介 四.创建没有资源限制的pod 4.1 创建没有资源限制的pod 4.2 内存消耗测试 五.使用resources字段配置资源限制 5 ...