QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#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
詳細信息
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