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. Spectre.Console-实现自己的CLI

    引言 最近发现自己喜欢用的 Todo 软件总是差点意思,毕竟每个人的习惯和工作流不太一样,我就想着自己写一个小的Todo 项目,核心的功能是自动记录 Todo 执行过程中消耗的时间(尤其面向程序员), ...

  2. Ado.Net 数据库访问技术(.Net 6版本)

    1. ADO.NET的前世今生 ADO.NET的名称起源于ADO(ActiveX Data Objects),是一个COM组件库,用于在以往的Microsoft技术中访问数据.之所以使用ADO.NET ...

  3. 一篇文章带你详细了解axios的封装

    axios 封装 对请求的封装在实际项目中是十分必要的,它可以让我们统一处理 http 请求.比如做一些拦截,处理一些错误等.本篇文章将详细介绍如何封装 axios 请求,具体实现的功能如下 基本配置 ...

  4. 一次 SSH 攻击与处理小记

    这是我在简书看到的一个作者经历,结合小编自己的一些实践,抛砖引玉,给大家分享一下. 有段时间发现集群异常卡顿.担心的事情终于发生了,使用命令 lastb 查看了一下,我的天呢,好多未知的 IP,我随便 ...

  5. 揭秘Spring依赖注入和SpEL表达式

    摘要:在本文中,我们深入探讨了Spring框架中的属性注入技术,包括setter注入.构造器注入.注解式属性注入,以及使用SpEL表达式进行属性注入. 本文分享自华为云社区<Spring高手之路 ...

  6. k8s+log-pilot日志收集

    github 地址:https://github.com/AliyunContainerService/log-pilot 介绍 log-pilot是一个很棒的 docker 日志工具.可以从dock ...

  7. 【Netty】02-入门

    二. Netty 入门 1. 概述 1.1 Netty 是什么? Netty is an asynchronous event-driven network application framework ...

  8. Solon 也是 SSE(Server Send Events)后端开发的优选

    Solon 2.3.6 在开发异步接口时,顺带也为 Solon Web 提供了 SSE (Server-Sent Events) 协议的支持插件: <dependency> <gro ...

  9. 一行命令使用 Docker 编译 Latex 文件,简单优雅

    使用 Docker 编译 LaTeX 文章 LaTeX 是一种常用的排版系统,它可以帮助用户创建漂亮.专业的文档.但是,安装和配置 LaTeX 比较麻烦,特别是对于初学者而言. Docker 是一个开 ...

  10. 基于 Surfel 的实时全局光照方案(Surfel-based Global Illumination)

    目录 Global Illumination based on Surfels [SIGGRAPH 2021] Surfel 持久化存储 surfel 数据组成 surfel 回收机制 Surfeli ...