记录一下每个位置最终到达的位置。然后每次操作排序。

#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<iostream>
using namespace std;
typedef long long LL;
const double pi=acos(-1.0),eps=1e-8;
void File()
{freopen("D:\\in.txt","r",stdin);freopen("D:\\out.txt","w",stdout);
}
inline int read()
{char c = getchar(); while(!isdigit(c)) c = getchar(); int x = 0;while(isdigit(c)) { x = x * 10 + c - '0'; c = getchar();  }return x;
}const int maxn=1010;
int T,n,m;
int a[maxn],b[maxn],f[maxn];
struct X{int pos;}s[maxn];bool cmp(X a,X b){return a.pos<b.pos;}int main()
{// File();scanf("%d",&T);while(T--){scanf("%d%d",&n,&m); memset(f,0,sizeof f);for(int i=1;i<=n;i++) scanf("%d",&a[i]);for(int i=1;i<=n;i++) scanf("%d",&b[i]);int ans=1;for(int i=1;i<=n;i++){s[i].pos=-1;for(int j=1;j<=n;j++){if(f[j]) continue;if(a[i]!=b[j]) continue;s[i].pos=j; f[j]=1; break;}if(s[i].pos==-1) ans=0;}for(int i=1;i<=m;i++){int L,R; scanf("%d%d",&L,&R);sort(s+L,s+R+1,cmp);}for(int i=1;i<=n;i++) if(s[i].pos!=i) ans=0;if(ans) printf("Yes\n");else printf("No\n");}return 0;
}

转载于:https://www.cnblogs.com/zufezzt/p/5765269.html

HDU 5821 Ball相关推荐

  1. 【贪心】 【HDU 5821】 Ball

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5821 题解(1001): http://bestcoder.hdu.edu.cn/blog/2016 ...

  2. 贪心(Ball,HDU 5821)

    又是很多人都做出来了的题目,自己却没有做出来. 主要是思维上的障碍. 一方面自己应该想好了再来写. 确定好时间复杂度,正确性,编码复杂度.有一定把握了再来写代码. 一开始想了个大概,然后开始写,一边写 ...

  3. HDOJ 5821 Ball 贪心 (16多校day8 1001) )

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5821 https://vjudge.net/contest/180311#problem/J 题意: ...

  4. python接口自动化用例管理_python接口自动化测试(六)-unittest-单个用例管理

    前面五节主要介绍了环境搭建和requests库的使用,可以使用这些进行接口请求的发送.但是如何管理接口案例?返回结果如何自动校验?这些内容光靠上面五节是不行的,因此从本节开始我们引入python单元测 ...

  5. 杭电OJ分类题目(1)

    原题出处:HDOJ Problem Index by Type,http://acm.hdu.edu.cn/typeclass.php 杭电OJ分类题目(1) HDU Introduction HDU ...

  6. HDU 2277 Change the ball

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2277 Change the ball Time Limit: 2000/1000 MS (Java/O ...

  7. hdu 1556:Color the ball(第二类树状数组 —— 区间更新,点求和)

    Color the ball Time Limit: 9000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) T ...

  8. HDU 1556 Color the ball (数状数组)

    Color the ball Time Limit: 9000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) T ...

  9. hdu 4605 Magic Ball Game (在线主席树/离线树状数组)

    版权声明:本文为博主原创文章,未经博主允许不得转载. hdu 4605 题意: 有一颗树,根节点为1,每一个节点要么有两个子节点,要么没有,每个节点都有一个权值wi .然后,有一个球,附带值x . 球 ...

最新文章

  1. java aio_java中的AIO
  2. python accept解析_python中requests库使用方法详解
  3. C语言数组的深入理解
  4. 5个酷毙的Python神器工具
  5. 去掉数组左右两边的引号
  6. 5404. 用栈操作构建数组
  7. 人类视觉计算理论经典著作,豆瓣评分9.7,中文版惊鸿面世!
  8. Makefile的学习笔记
  9. 只想着一直调用一直爽, 那API凭证泄漏风险如何破?
  10. CCNA考试题库中英文翻译版及答案6
  11. 一、二层交换机构建局域网
  12. CVPR2020论文列表(中英对照)
  13. 巧用CSS文件愚人节恶搞
  14. Sass系统技术选型笔记(1)OS
  15. 史上最简单的制作安装系统U盘工具
  16. debug——生成log
  17. Android Xposed模块动态隐藏桌面图标
  18. 小米手机夜间模式在哪设置?仅需2个步骤
  19. Pytorch深度学习(一):前馈神经网络(FNN)
  20. 深度好文推荐阅读——阿里云的这群疯子

热门文章

  1. BF算法和KMP算法
  2. 使用Docker Compose安装mysql
  3. python如何处理表格_Python是如何处理Excel表格的?方法简单!
  4. android studio差异化,productFlavors + buildTypes + signingConfigs 构建差异化 Android 应用
  5. python批量生成图_python图像处理-批量生成纯色图片
  6. 微信小程序点击页面tab栏切换
  7. linux io重定向指令,Linux基础知识之 IO重定向
  8. ie浏览器在线使用_全球浏览器5月份市场份额公布!Chrome和Edge浏览器迎来新一轮“撕X”大战...
  9. Token令牌 Redis 案例
  10. leetcode -day19 Convert Sorted List to Binary Search Tree