首页 > 其他分享 >LightOJ - 1374 Confusion in the Problemset (模拟)

LightOJ - 1374 Confusion in the Problemset (模拟)

时间:2023-06-08 14:01:50浏览次数:57  
标签:set Confusion LightOJ number rule page 1374 include pages

Time Limit: 2000MS

Memory Limit: 32768KB

64bit IO Format: %lld & %llu

LightOJ - 1374


Confusion in the Problemset



Submit Status




Description




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




2

4

0 3 1 2

4

1 3 3 3






Sample Output




Case 1: yes

Case 2: no




Source




Problem Setter: Md. Mahbubul Hasan



Special Thanks: Md. Towhidul Islam Talukder, Jane Alam Jan




//题意:输入一个n,接下来输入n个数a[i]



输入的n个数a[i]表示在这个数前面有几个数或者是在这个数后面有几个数。



//思路:



将每个数的个数记录一下,再用一层for模拟每个位置应该放的数就行了







#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<iostream>
#define N 10010
using namespace std;
int a[N];
int main()
{
	int t,T=1,n,m,i;
	scanf("%d",&t);
	while(t--)
	{
		scanf("%d",&n);
		memset(a,0,sizeof(a));
		for(i=0;i<n;i++)
		{
			scanf("%d",&m);
			a[m]++;
		}
		int flag=0;
		for(i=1;i<=n;i++)
		{
			if(a[n-i])
				a[n-i]--;
			else if(a[i-1])
				a[i-1]--;
			else
			{
				flag=1;
				break;
			}
		}
		printf("Case %d: ",T++);
		if(flag)
			printf("no\n");
		else
			printf("yes\n");
	}
	return 0;
}





标签:set,Confusion,LightOJ,number,rule,page,1374,include,pages
From: https://blog.51cto.com/u_16079508/6439540

相关文章

  • LightOJ - 1058 Parallelogram Counting (数学几何&技巧)给n个点求组成平行四边形个数
    LightOJ-1058ParallelogramCountingTimeLimit: 2000MSMemoryLimit: 32768KB64bitIOFormat: %lld&%lluSubmit StatusDescriptionThereare n distinctpointsintheplane,givenbytheirintegercoordinates.Findthenumberofparallelogramswhosever......
  • sklearn.metrics.confusion_matrix—计算混淆矩阵来评估分类的准确性
    在分类模型的性能评估指标总结中,已讲过混淆矩阵形式,接下来将介绍如何通过sklearn库中的confusion_matrix函数快速获得混淆矩阵。语法格式sklearn.metrics.confusion_matrix(y_true, y_pred, *, labels=None, sample_weight=None, normalize=None)参数解释:y_true:真实标......
  • LightOJ1007---Mathematically Hard (欧拉函数)
    Mathematicallysomeproblemslookhard.Butwiththehelpofthecomputer,someproblemscanbeeasilysolvable.Inthisproblem,youwillbegiventwointegersaandb.Youhavetofindthesummationofthescoresofthenumbersfromatob(inclusive).T......
  • LightOJ 1348 Aladdin and the Return Journey (树链剖分)
    树链剖分模板题。最近一直有比赛。。好长时间没写了。明显生疏了。。找个模板题熟悉一下。代码如下:#include<iostream>#include<string.h>#include<math.h>#include<queue>#include<algorithm>#include<stdlib.h>#include<map>#include<set>#include......
  • LightOJ - 1044 Palindrome Partitioning(DP)
    题目大意:给你一个字符串,要求你对字符串进行划分,使得划分出来的子串都是回文串,且子串数量达到最小解题思路:用dp[i]表示前i个字符划分成回文串,需要划分成多少个部分接着枚举j,如果[i,j]回文,那么dp[i]=min(dp[i],dp[j-1]+1)#include<cstdio>#include<cstring>#include<al......
  • LightOJ - 1300 Odd Personality(边双连通+奇圈判定)
    题目大意:给出一张无向图,要求找出符合条件的点条件如下:从该点出发,经过一定数量的边,又回到该点,经过的边不能重复经过,且经过的边的数量为奇数解题思路:要回到原点,且不能重复经过边,只能在边双连通分量中找了接着要判断的是有多少个点,只要边双连通分量中有奇圈,那么这个连通分量中的所......
  • LightOJ - 1400 Employment(婚姻稳定问题)
    题目大意:在一个party上,有N个男的,N个女的,要求你将其配对,使其满足1.男生u和女生v还没配对2.他们喜欢对方的程度都大于喜欢各自当前舞伴的程度如果出现了2的情况,他们就会抛下当前的舞伴,另外组成一对解题思路:这题的话,就是婚姻稳定问题,他的解决方法是,男士不断的求婚,而女士不断的拒......
  • LightOJ - 1063 Ant Hills(割点)
    题目大意:求无向图中,有多少个割点解题思路:模版题了#include<cstdio>#include<cstring>#include<vector>#include<stack>usingnamespacestd;#definemax(a,b)((a)>(b)?(a):(b))#definemin(a,b)((a)<(b)?(a):(b))constintMAXNODE=10005;constintM......
  • LightOJ - 1041 Road Construction(最小生成树)
    题目大意:给你N条边,看能否形成最小生成树,如果存在,输出值,不存在,另外输出解题思路:模版题#include<cstdio>#include<cstring>#include<algorithm>#include<vector>#include<map>#include<string>#include<iostream>usingnamespacestd;constintMAXNOD......
  • leetcode-1374-easy
    GenerateaStringWithCharactersThatHaveOddCountsGivenanintegern,returnastringwithncharacterssuchthateachcharacterinsuchstringoccursan......