QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#399502#2820. 令人难以忘记的题目名称ucup-team1251WA 28ms8296kbC++17962b2024-04-26 14:03:392024-04-26 14:03:40

Judging History

This is the latest submission verdict.

  • [2024-04-26 14:03:40]
  • Judged
  • Verdict: WA
  • Time: 28ms
  • Memory: 8296kb
  • [2024-04-26 14:03:39]
  • Submitted

answer

#include<bits/stdc++.h>
#define mem(i,a) memset(i,a,sizeof(i))
#define inf 0x3f3f3f3f3f3f3f3f
#define PII pair<int,int>
#define int  long long
#define endl '\n'
using namespace std;
const int maxn = 3e5 + 5;
int a[maxn],b[maxn];
void solve() {
	int n,p;
	cin>>n>>p;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		b[i]=a[i]%p;
		a[i]%=2;
	}
	if(p!=2){
		sort(b+1,b+n+1);
		if(b[1]!=b[n]){
			cout<<"-1"<<endl;
			return;
		}
		cout<<1<<endl;
		return;
	}
	
	int cnt=0;
	for(int i=3;i<=n;i++){
		if(i==1){
			if(a[i]!=a[n-1]){
				cout<<-1<<endl;
				return ;
			}
		}
		else if(i==2){
			if(a[i]!=a[n]){
				cout<<-1<<endl;
				return;
			}
		}
		else {
			if(a[i-2]!=a[i]){
				cout<<-1<<endl;
				return;
			}
		}
		cnt+=a[i];
	}
	if(cnt==n){
		cout<<1<<endl;
		return;
	}
	if(cnt==0){
		cout<<1<<endl;
		return;
	}
	cout<<2<<endl;
}
signed main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(0);
	// int _;
	// cin >> _;
	// while (_--)
		solve();
	return 0;
}


詳細信息

Test #1:

score: 0
Wrong Answer
time: 28ms
memory: 8296kb

input:

297910 31
113232 54750 68197 111096 34111 93605 123591 18035 81089 116592 24694 31596 60286 93804 59021 38782 20907 112337 52523 99808 71474 60598 132242 65758 78755 58580 4515 138889 92332 154059 2039 74180 53778 93861 30218 87862 32418 153778 129564 113461 138995 154233 145061 44213 116624 72685 8...

output:

-1

result:

wrong answer 1st lines differ - expected: '29019', found: '-1'