QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#842948#9969. Kindergarten Squareucup-team4435#RE 1ms3512kbC++20905b2025-01-04 16:08:032025-01-04 16:08:03

Judging History

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

  • [2025-01-04 16:08:03]
  • 评测
  • 测评结果:RE
  • 用时:1ms
  • 内存:3512kb
  • [2025-01-04 16:08:03]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using ld = long double;

#define all(a) begin(a), end(a)
#define len(a) int((a).size())

void solve(int /* test_num */) {
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    A--, B--, C--, D--;
    int m = C - A;

    for (int n = 2; n <= int(1e5); n++) {
        bool ok = true;
        ok &= A / m == B / m;
        ok &= C / m == D / m;
        ok &= B % m == A % m + 1;
        ok &= D % m == C % m + 1;
        ok &= C / m == A / m + 1;
        ok &= max({A, B, C, D}) < 1ll * n * m;
        if (ok) {
            cout << n << ' ' << m << '\n';
            return;
        }
    }
    cout << "-1\n";
}

int main() {
    cin.tie(nullptr)->sync_with_stdio(false);

    int tests;
    cin >> tests;
    for (int test_num = 1; test_num <= tests; test_num++) {
        solve(test_num);
    }
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 3512kb

input:

4
6 7
10 11
2 3
4 5
8 5
5 13
1 2
5 6

output:

3 4
-1
-1
2 4

result:

ok All testcases passed.

Test #2:

score: -100
Runtime Error

input:

10
1 2
4 5
4 3
2 1
1 2
5 6
2 3
5 6
2 3
6 7
3 4
6 7
2 1
3 4
1 2
2 3
2 3
3 4
7 7
7 7

output:


result: