QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#630133 | #6746. Merge the Rectangles | Qzong# | WA | 0ms | 3556kb | C++14 | 1.0kb | 2024-10-11 16:41:00 | 2024-10-11 16:41:02 |
Judging History
answer
#include <bits/stdc++.h>
using i64 = long long;
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int n; std::cin >> n;
std::vector<int> a(n);
bool flag = 0;
for (int i = 0; i < n; ++i) {
std::cin >> a[i];
}
for (int i = 1; i < n; ++i) {
if (a[i] != a[i - 1]) {
flag = 1;
}
}
if (!flag) {
if (a[0] == 0) {
std::cout << "0\n";
} else {
std::cout << n + 1 << "\n";
}
return 0;
}
bool ok = 0;
int d = (a[1] - a[0] + n) % n;
for (int i = 2; i < n; ++i) {
if ((a[i] - a[i - 1] + n) % n != d) {
ok = 1;
break;
}
}
if ((a[0] - a[n - 1] + n) % n != d) {
ok = 1;
}
if (ok) {
std::cout << "-1\n";
} else {
if (a[0] != 0) {
std::cout << 1 + d << "\n";
} else {
std::cout << d << "\n";
}
}
return 0;
}
// 1 3 2 4 5 0
// 0 1 2 3 4 5
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3556kb
input:
3 4 0000 0111 101 101 110
output:
-1
result:
wrong output format YES or NO expected, but -1 found