QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#399814 | #2820. 令人难以忘记的题目名称 | ucup-team1251 | WA | 19ms | 4728kb | C++17 | 1.7kb | 2024-04-26 17:58:23 | 2024-04-26 17:58:24 |
Judging History
answer
// #pragma GCC optimize(2) //O2优化开启
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;
typedef long long i64;
typedef pair<int, int> PII;
typedef unsigned long long ull;
int a[300010];
bitset<300010> bt;
int n, p;
bool ff(int x) {
int pp = 0;
while (!bt[x]) {
bt[x] = 1;
if (a[x] != pp) {
return 0;
}
x++;
pp++;
if (x > n) {
x -= n;
}
if (pp >= p) {
pp -= p;
}
}
return 1;
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n >> p;
set<int> st;
for (int i = 1; i <= n; i++) {
cin >> a[i];
a[i] %= p;
st.insert(a[i]);
}
// if (st.size() == 1 && a[1] == 0) {
// cout << "0";
// return 0;
// }
if (st.size() == 1) {
cout << "1";
return 0;
}
if (n % p == 0 && (p < 5)) {
int flag = 1;
for (int i = p + 1; i <= n; i++) {
if (a[i] != a[i - p]) {
flag = 0;
break;
}
}
if (flag) {
cout << p;
return 0;
}
}
if (p > 2) {
cout << "-1";
return 0;
}
if (n % 2 == 1) {
cout << "-1";
return 0;
}
if (n == 4) {
int cnt = 0;
for (int i = 1; i <= n; i++) {
cnt += a[i];
}
if (cnt == 2) {
for (int i = 2; i <= n; i++) {
if (a[i] == a[i - 1]) {
cout << "3";
return 0;
}
}
}
}
cout<<"-1";
}
详细
Test #1:
score: 0
Wrong Answer
time: 19ms
memory: 4728kb
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'