1374 - Confusion in the Problemset
Time Limit: 2 second(s) Memory Limit: 32 MB

A small confusion in a problem set may ruin the whole contest. So, most of the problem setters try their best to remove any kind of ambiguity from the set. But sometimes it is not that important. For example, the mock contest of ICPC Dhaka Regional. As it is mock contest so we are not that serious with the set. We printed two problems, problem A in Page 1 and Problem B in Page 2. Then we remembered that we had to give rule of the contest too. Thus we printed the rule page. But we did not notice that the rule page was printed with Page 2. We were stapling 3 pages together. First rule page, then Problem A and at the last Problem B. So, the written page numbers were, 2, 1 and 2. This looked odd. But we already printed all the pages and if we want to fix the issue we had no other way but to print all the three pages. One among us suggested an explanation, "Well, first 2 means there are 2 pages after this page. 1 also means there is 1 page after this page. But the 2 in last page means there are 2 pages before this page." Interesting observation indeed! So we came up with a rule which is, page numberings of all the n pages are valid, if the page number at a page denotes number of page before this page or number of page after this page.

So with this rule, {3, 1, 2, 0} is valid but {3, 3, 1, 3} is not valid.

Input

Input starts with an integer T (≤ 60), denoting the number of test cases.

Each case starts with a line an integer n (1 ≤ n ≤ 10000) denoting the number of pages in the problem-set. The next line contains n space separated integers denoting the page number written on the pages. The integers lie in the range [0, 106].

Output

For each case, print the case number and "yes" if the pages can be shuffled somehow to meet the given restrictions. Otherwise print "no".

Sample Input

Output for Sample Input

2

4

0 3 1 2

4

1 3 3 3

Case 1: yes

Case 2: no

Notes

  1. For case 1, the pages can be shuffled in several ways so that the page numbering is valid. One of the valid shuffles is 3, 1, 2, 0.
  2. For case 2, there is no valid way to shuffle these.

PROBLEM SETTER: MD. MAHBUBUL HASAN
SPECIAL THANKS: MD. TOWHIDUL ISLAM TALUKDER, JANE ALAM JAN
题意:n个数字,问能否把这些数字放在合适的位置,每个位置的数字有两种含义:他前面有a[i]个数字或者他后面有a[i]个数字;
思路:
先将给的数统计到数组中,然后重前到后扫一遍,因为两个位置是对称的,要么选i+1,要么选n-i-1;所以当前的为置这两种情况选那个都行。
 1 #include<stdio.h>
2 #include<algorithm>
3 #include<iostream>
4 #include<string.h>
5 #include<stdlib.h>
6 #include<queue>
7 #include<set>
8 #include<vector>
9 #include<map>
10 using namespace std;
11 int ans[20000];
12 int flag[1000005];
13 int main(void)
14 {
15 int i,j,k;
16 int s;
17 scanf("%d",&k);
18 for(s=1; s<=k; s++)
19 {
20 int n,m;memset(flag,0,sizeof(flag));
21 scanf("%d",&n);
22 for(i=0; i<n; i++)
23 {
24 scanf("%d",&ans[i]);
25 flag[ans[i]]++;
26 }
27 int ask=0;
28 for(i=0;i<n;i++)
29 {
30 int q=i;
31 int p=n-i-1;
32 if(flag[q])
33 {
34 flag[q]--;
35 }
36 else if(flag[p])
37 {
38 flag[p]--;
39 }
40 else ask=1;
41 }
42 printf("Case %d: ",s);
43 if(ask)
44 printf("no\n");
45 else printf("yes\n");
46 }
47 return 0;
48 }

1374 - Confusion in the Problemset的更多相关文章

  1. Data type confusion: what is an int(11)?

    http://everythingmysql.ning.com/profiles/blogs/data-type-confusion-what-is-an Over and over I see cu ...

  2. Gym 100851E Easy Problemset (模拟题)

    Problem E. Easy ProblemsetInput file: easy.in Output file: easy.outPerhaps one of the hardest problems ...

  3. 九度0J 1374 所有员工年龄排序

    题目地址:http://ac.jobdu.com/problem.php?pid=1374 题目描述: 公司现在要对所有员工的年龄进行排序,因为公司员工的人数非常多,所以要求排序算法的效率要非常高,你 ...

  4. ML01 机器学习后利用混淆矩阵Confusion matrix 进行结果分析

      目标: 快速理解什么是混淆矩阵, 混淆矩阵是用来干嘛的. 首先理解什么是confusion matrix 看定义,在机器学习领域,混淆矩阵(confusion matrix),又称为可能性表格或是 ...

  5. 混淆矩阵(Confusion matrix)的原理及使用(scikit-learn 和 tensorflow)

    原理 在机器学习中, 混淆矩阵是一个误差矩阵, 常用来可视化地评估监督学习算法的性能. 混淆矩阵大小为 (n_classes, n_classes) 的方阵, 其中 n_classes 表示类的数量. ...

  6. HDU 1374

    http://acm.hdu.edu.cn/showproblem.php?pid=1374 已知三点坐标,求三点确定的圆的周长 #include <iostream> #include ...

  7. 性能度量之Confusion Matrix

    例子:一个Binary Classifier 假设我们要预测图片中的数字是否为数字5.如下面代码. X_train为训练集,每一个instance为一张28*28像素的图片,共784个features ...

  8. 机器学习-Confusion Matrix混淆矩阵、ROC、AUC

    本文整理了关于机器学习分类问题的评价指标——Confusion Matrix.ROC.AUC的概念以及理解. 混淆矩阵 在机器学习领域中,混淆矩阵(confusion matrix)是一种评价分类模型 ...

  9. CSU 1374 Restore Calculation 数位DP

    题意: 给你三个数A, B, C(没有前导0),但是其中某些位不知道. 问A+B=C成立有多少种情况. 思路: 从最后一位往前推,枚举A, B的每一种情况,考虑进位和不进位两种情况. 代码: #inc ...

随机推荐

  1. Oracle-一张表中增加计算某列值重复的次数列,并且把表中其他列也显示出来,或者在显示过程中做一些过滤

    总结: 1.计算某列值(数值or字符串)重复的次数 select 列1,count( 列1 or *) count1  from table1 group by 列1 输出的表为:第一列是保留唯一值的 ...

  2. Beautiful Soup解析库的安装和使用

    Beautiful Soup是Python的一个HTML或XML的解析库,我们可以用它来方便地从网页中提取数据.它拥有强大的API和多样的解析方式.官方文档:https://www.crummy.co ...

  3. SCRDet——对小物体和旋转物体更具鲁棒性的模型

    引言 明确提出了三个航拍图像领域内面对的挑战: 小物体:航拍图像经常包含很多复杂场景下的小物体. 密集:如交通工具和轮船类,在航拍图像中会很密集.这个DOTA数据集的发明者也提到在交通工具和轮船类的检 ...

  4. accent, access, accident

    accent A colon (:) is used to represent a long vowel [元音], e.g. sheet /ʃiːt/ and shit /ʃit/. The wor ...

  5. nextcloud搭建私有云盘

    一.基础环境准备 1.安装一台centos7的linux服务器. # 系统初始化 # 如果时区不对,请修改时区 #mv /etc/localtime /etc/localtime_bak #ln -s ...

  6. 在 Apple Silicon Mac 上 DFU 模式恢复 macOS 固件

    DFU 模式全新安装 macOS Big Sur 或 macOS Monterey 请访问原文链接:https://sysin.org/blog/apple-silicon-mac-dfu/,查看最新 ...

  7. Linux启动初始化配置文件

    Linux启动初始化配置文件(1)/etc/profile 登录时,会执行. 全局(公有)配置,不管是哪个用户,登录时都会读取该文件. (2)/ect/bashrc Ubuntu没有此文件,与之对应的 ...

  8. gitlab之数据备份恢复

    备份#备份的时候,先通知相关人员服务要听 ,停止两个服务,并影响访问 root@ubuntu:/opt/web1# gitlab-ctl stop unicorn ok: down: unicorn: ...

  9. 【C/C++】例题3-6 环状序列/算法竞赛入门经典/数组和字符串

    [字典序比较] 对于两个字符串,比较字典序,从第一个开始,如果有两位不一样的出现,那么哪个的ASCII码小,就是字典序较小.如果都一样,那么短的小. [题目] 输入一个环状串,输出最小的字典序序列. ...

  10. [BUUCTF]PWN——bjdctf_2020_router

    bjdctf_2020_router 附件 步骤: 例行检查,64位程序,开启了NX保护 本地试运行一下程序,看看大概的情况 会让我们选择,选择4.root,没什么用,但是注意了,这边选1会执行pin ...