QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#630133#6746. Merge the RectanglesQzong#WA 0ms3556kbC++141.0kb2024-10-11 16:41:002024-10-11 16:41:02

Judging History

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

  • [2024-10-11 16:41:02]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3556kb
  • [2024-10-11 16:41:00]
  • 提交

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