QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#127827#1171. Integer Array ShuffleDr_GlitchWA 1ms3600kbC++141.0kb2023-07-20 09:18:052023-07-20 09:18:06

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-20 09:18:06]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3600kb
  • [2023-07-20 09:18:05]
  • 提交

answer

#include<bits/stdc++.h>
#define init read()
using namespace std;
int n,ans=0;
vector<int>vec;
inline int read()
{
	int mmm=0,ff=1;char xx=getchar();
	while((xx<'0'||xx>'9')&&xx!='-')xx=getchar();
	if(xx=='-')ff=-1,xx=getchar();
	while(xx>='0'&&xx<='9')
	mmm=mmm*10+xx-'0',xx=getchar();
	return mmm*ff;
}
inline void write(int x)
{
	if(x<0)
	{
		putchar('-');
		x=-x;
	}
	if(x>9)write(x/10);
	putchar('0'+x%10);
}
int main()
{
	//freopen("qoj1171.in","r",stdin);
	//freopen("qoj1171.out","w",stdout);
	n=init;bool flag=true;int last=0;
	for(int i=1;i<=n;i++)
	{
		int x=init;if(x<last)flag=false;
		last=x;
		vec.emplace_back(x);
	}
	if(vec.size()==1u||flag)
	{
		puts("0");
		return 0;
	}
	last=vec[0];bool up=true;
	for(int i=1;(unsigned)i<vec.size();i++)
	{
		int now=vec[i];
		if(now>=last&&up)
		{
			if(i==1)ans=1;
			last=now;
			continue;
		}
		if(now<=last&&!up)
		{
			if(i==1)ans=1;
			last=now;
			continue;
		}
		last=now;
		up=!up;ans++;
	}
	ans++;
	write(ceil(log2(ans)));putchar('\n');
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 3600kb

input:

3
2 2 5

output:

0

result:

ok 1 number(s): "0"

Test #2:

score: -100
Wrong Answer
time: 1ms
memory: 3412kb

input:

6
1 5 8 10 3 2

output:

2

result:

wrong answer 1st numbers differ - expected: '1', found: '2'