QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#843794#9969. Kindergarten Squareucup-team3635#AC ✓0ms3744kbC++2310.9kb2025-01-05 02:28:232025-01-05 02:28:23

Judging History

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

  • [2025-01-05 02:28:23]
  • 评测
  • 测评结果:AC
  • 用时:0ms
  • 内存:3744kb
  • [2025-01-05 02:28:23]
  • 提交

answer

#ifndef SorahISA
#define SorahISA
#include SorahISA __FILE__ SorahISA

/// A B
/// C D

void solve() {
    int A, B, C, D; cin >> A >> B >> C >> D;
    if (A + 1 != B or C + 1 != D or C - A != D - B or B >= C) { print(-1); return; }
    if (A % (C - A) == 0 or C % (C - A) == 0) { print(-1); return; }
    print(100'000, C - A);
}

int32_t main() {
    fastIO();
    
    int t = 1; cin >> t;
    for (int _ = 1; _ <= t; ++_) {
        // cout << "Case #" << _ << ": ";
        solve();
    }
    
    return 0;
}

#else

#ifdef local
#define _GLIBCXX_DEBUG 1
#endif
#pragma GCC optimize("Ofast", "unroll-loops")
#include <bits/stdc++.h>
using namespace std;
// #include <bits/extc++.h>
// #include <tr2/dynamic_bitset>

using i64 = long long;
using i128 = __int128;
#define int i64
using f80 = long double;
using f128 = __float128;
#define double f80
using pii = pair<int, int>;
template <typename T> using Prior = std::priority_queue<T>;
template <typename T> using prior = std::priority_queue<T, vector<T>, greater<T>>;

// #define X first
// #define Y second
#define eb emplace_back
#define ef emplace_front
#define ee emplace
#define pb pop_back
#define pf pop_front
#define ALL(x) begin(x), end(x)
#define RALL(x) rbegin(x), rend(x)
#define SZ(x) ((int)(x).size())
#define popcnt(x) __builtin_popcountll(x)

// template <size_t D, typename T> struct Vec : vector<Vec<D-1, T>> {
//     static_assert(D >= 1, "Vector dimension must be greater than zero!");
//     template <typename... Args> Vec(int n = 0, Args... args) : vector<Vec<D-1, T>>(n, Vec<D-1, T>(args...)) {}
// };

// template <typename T> struct Vec<1, T> : vector<T> {
//     Vec(int n = 0, const T& val = T()) : vector<T>(n, val) {}
// };

template <typename T> ostream& operator << (ostream &os, const vector<T> &vec)
{ for (size_t i = 0; i < size(vec); ++i) { if (i) os << " "; os << vec[i]; } return os; }

#ifdef local
#define fastIO() void()
#define debug(...) \
    _color.emplace_back("\u001b[31m"), \
    fprintf(stderr, "%sAt [%s], line %d: (%s) = ", _color.back().c_str(), __FUNCTION__, __LINE__, #__VA_ARGS__), \
    _do(__VA_ARGS__), _color.pop_back(), \
    fprintf(stderr, "%s", _color.back().c_str())
#define print(...) \
    fprintf(stdout, "%s", "\u001b[36m"), \
    _P(__VA_ARGS__), \
    fprintf(stdout, "%s", "\u001b[0m")

deque<string> _color{"\u001b[0m"};

template <typename T> concept is_string = is_same_v<T, string&> or is_same_v<T, const string&>;
template <typename T> concept is_iterable = requires (T _t) { begin(_t); };

template <typename T> inline void _print_err(T &&_t);
template <typename T> inline void _print_err(T &&_t) requires is_iterable<T> and (not is_string<T>);
template <size_t I, typename ...U> inline typename enable_if<I == sizeof...(U), void>::type _print_err(const tuple<U...> &);
template <size_t I, typename ...U> inline typename enable_if<I <  sizeof...(U), void>::type _print_err(const tuple<U...> &_t);
template <size_t I, typename ...U> inline typename enable_if<I == sizeof...(U), void>::type _print_err(tuple<U...> &);
template <size_t I, typename ...U> inline typename enable_if<I <  sizeof...(U), void>::type _print_err(tuple<U...> &_t);
template <typename T, typename U> ostream& operator << (ostream &os, const pair<T, U> &_tu);

inline void _do() { cerr << "\n"; }
template <typename T> inline void _do(T &&_t) { _print_err(_t), cerr << "\n"; }
template <typename T, typename ...U> inline void _do(T &&_t, U &&..._u) { _print_err(_t), cerr << ", ", _do(_u...); }
#else
#define fastIO() cin.tie(0)->sync_with_stdio(0)
#define debug(...) void()
#define print(...) _P(__VA_ARGS__)
#endif

inline void _P() { cout << "\n"; }
template <typename T> inline void _P(T &&_t) { cout << _t << "\n"; }
template <typename T, typename ...U> inline void _P(T &&_t, U &&..._u) { cout << _t << " ", _P(_u...); }

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

inline int getRand(int L, int R) {
    if (L > R) swap(L, R);
    return (int)(rng() % ((uint64_t)R - L + 1) + L);
}

template <typename T, typename U> bool chmin(T &lhs, U rhs) { return lhs > rhs ? lhs = rhs, 1 : 0; }
template <typename T, typename U> bool chmax(T &lhs, U rhs) { return lhs < rhs ? lhs = rhs, 1 : 0; }

template <typename T> void make_unique(vector<T> &vec) {
    if (not is_sorted(ALL(vec))) sort(ALL(vec));
    vec.erase(unique(ALL(vec)), end(vec));
}

/// below are Fast I/O and _print_err templates ///

/*
/// Fast I/O by FHVirus ///
/// https://fhvirus.github.io/blog/2020/fhvirus-io/ ///

#include <unistd.h>

const int S = 65536;

int OP = 0;
char OB[S];

inline char RC() {
    static char buf[S], *p = buf, *q = buf;
    return p == q and (q = (p = buf) + read(0, buf, S)) == buf ? -1 : *p++;
}

inline int RI() {
    static char c;
    int a;
    while (((c = RC()) < '0' or c > '9') and c != '-' and c != -1);
    if (c == '-') {
        a = 0;
        while ((c = RC()) >= '0' and c <= '9') a *= 10, a -= c ^ '0';
    }
    else {
        a = c ^ '0';
        while ((c = RC()) >= '0' and c <= '9') a *= 10, a += c ^ '0';
    }
    return a;
}

inline void WI(int n, char c = '\n') {
    static char buf[20], p;
    if (n == 0) OB[OP++] = '0';
    p = 0;
    if (n < 0) {
        OB[OP++] = '-';
        while (n) buf[p++] = '0' - (n % 10), n /= 10;
    }
    else {
        while (n) buf[p++] = '0' + (n % 10), n /= 10;
    }
    for (--p; p >= 0; --p) OB[OP++] = buf[p];
    OB[OP++] = c;
    if (OP > S-20) write(1, OB, OP), OP = 0;
}

/// Fast I/O by FHVirus ///
/// https://fhvirus.github.io/blog/2020/fhvirus-io/ ///
*/

#ifdef local

template <typename T> inline void _print_err(T &&_t) { cerr << _t; }

template <typename T> inline void _print_err(T &&_t) requires is_iterable<T> and (not is_string<T>) {
    _color.emplace_back(_color.back()), ++_color.back()[3];
    cerr << _color.back() << "[";
    for (bool _first = true; auto &_x : _t) {
        if (!_first) cerr << ", ";
        _print_err(_x), _first = false;
    }
    cerr << "]" << (_color.pop_back(), _color.back());
}

template <typename T, typename U> ostream& operator << (ostream &os, const pair<T, U> &_tu) {
    _color.emplace_back(_color.back()), ++_color.back()[3];
    cerr << _color.back() << "(";
    _print_err(_tu.first), cerr << ", ", _print_err(_tu.second);
    cerr << ")" << (_color.pop_back(), _color.back());
    return os;
}

template <size_t I = 0, typename ...U> inline typename enable_if<I == sizeof...(U), void>::type _print_err(const tuple<U...> &) {
    cerr << ")" << (_color.pop_back(), _color.back());
}

template <size_t I = 0, typename ...U> inline typename enable_if<I <  sizeof...(U), void>::type _print_err(const tuple<U...> &_t) {
    if (!I) {
        _color.emplace_back(_color.back()), ++_color.back()[3];
        cerr << _color.back();
    }
    cerr << (I ? ", " : "("), _print_err(get<I>(_t)), _print_err<I+1, U...>(_t);
}

template <size_t I = 0, typename ...U> inline typename enable_if<I == sizeof...(U), void>::type _print_err(tuple<U...> &) {
    cerr << ")" << (_color.pop_back(), _color.back());
}

template <size_t I = 0, typename ...U> inline typename enable_if<I <  sizeof...(U), void>::type _print_err(tuple<U...> &_t) {
    if (!I) {
        _color.emplace_back(_color.back()), ++_color.back()[3];
        cerr << _color.back();
    }
    cerr << (I ? ", " : "("), _print_err(get<I>(_t)), _print_err<I+1, U...>(_t);
}

#endif

#endif

/**
 *                                                                                                                 
 *                                                                                                                 
 *                                                                                                                 
 *                            iiiiii         iiiiiiiiii       iiiiiiiiiiiiii                                       
 *                       iiiiiiiiiiiii   iiiiiii    iiii    iiiiiiiiiiiiiii                          ii   iiii     
 *                    iiiiiiii     iiiiiiiii         iiii       iiii iii              iii          iiiiiiiiii      
 *                 iiiiiii          iiiiii           iiii    iiii   ii           iiiiiiiiii      iiii iiii         
 *               iiiiii            iiiii             iiii iiii        iii      iiii    iiiiiiiiiiiiiiiii  ii       
 *             iiiiii            iiiiiii            iiiiiii       iiiiiiii   iii    iiiiiiiiiiiiii iii  iiii       
 *           iiiiii             iiiiiii            iiiii   ii   iiii       iiiiiiiiiii iiii  iii iiii iiii      iii
 *          iiiii              iiiiiiii       ii        iiiii iiii    iiiiiiiii        iii iii  iii  iii  ii  iiii 
 *        iiiiii              iiiiiiii      iiiii     iiiii iiiiiiiiiiiiiiii         iii  iii  ii  iii  iii iiii   
 *       iiiii                 iiiiii     iiii     iiiiii iiiiiii    iii iii       iiii  ii   i   ii  iii  iii     
 *     iiiiii                            iiii  iiiiiiiiiiiiiii       iii iiii   iiiii  iii  ii  iii  iii  ii       
 *    iiiii                              iiiiiiii iiiiiiiiii       iiii   iiiiiiiii            ii  iii  ii         
 *   iiiii                                     iiiiii  iiii      iiiii              iii      ii   ii  i            
 * iiiiii                                  iiiiiiii   iiiii    iiiii                        ii  ii   ii            
 * iiiii                                iiii  iiii    iiiiiiiiiiii                             ii                  
 *  iii                              iiii   iiii       iiiiiiii                                                    
 *                                iiiii   iiii                                                                     
 *                              iiii     iiii                                                                      
 *                            iiii    iiiii                                                                        
 *                          iii     iiiii                                                                          
 *                        iii     iiiii                                                                            
 *                       iii   iiiiii                                                                              
 *                       iiiiiiiii                                                                                 
 *                       iiiiii                                                                                    
 *                                                                                                                 
 *                                                                                                                 
 *                                                                                                                 
**/

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3576kb

input:

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

output:

100000 4
-1
-1
100000 4

result:

ok All testcases passed.

Test #2:

score: 0
Accepted
time: 0ms
memory: 3704kb

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:

100000 3
-1
100000 4
100000 3
100000 4
-1
-1
-1
-1
-1

result:

ok All testcases passed.

Test #3:

score: 0
Accepted
time: 0ms
memory: 3640kb

input:

10
1 1
1 1
1 2
3 4
1 2
5 7
4 5
7 8
1001 1002
1003 1004
1001 1002
1005 1007
1004 1005
1007 1008
249 250
251 252
250 251
250 251
250 250
250 251

output:

-1
100000 2
-1
100000 3
100000 2
-1
100000 3
100000 2
-1
-1

result:

ok All testcases passed.

Test #4:

score: 0
Accepted
time: 0ms
memory: 3672kb

input:

10
249 251
250 251
249 250
250 251
249 250
251 251
249 250
251 251
51 52
61 62
50 52
61 62
52 52
61 62
51 51
61 62
51 53
61 62
51 52
60 62

output:

-1
-1
-1
-1
100000 10
-1
-1
-1
-1
-1

result:

ok All testcases passed.

Test #5:

score: 0
Accepted
time: 0ms
memory: 3556kb

input:

10
51 52
62 62
51 52
61 61
51 52
61 63
109 110
119 120
108 110
119 120
110 110
119 120
109 109
119 120
109 111
119 120
109 110
118 120
109 110
120 120

output:

-1
-1
-1
100000 10
-1
-1
-1
-1
-1
-1

result:

ok All testcases passed.

Test #6:

score: 0
Accepted
time: 0ms
memory: 3696kb

input:

10
109 110
119 119
109 110
119 121
1050 1075
2050 2075
1 2
1001 1002
101 102
1101 1102
999 1000
1999 2000
2 2
1001 1002
1 1
1001 1002
1 3
1001 1002
1 2
1000 1002

output:

-1
-1
-1
100000 1000
100000 1000
100000 1000
-1
-1
-1
-1

result:

ok All testcases passed.

Test #7:

score: 0
Accepted
time: 0ms
memory: 3612kb

input:

10
1 2
1002 1002
1 2
1001 1001
1 2
1001 1003
100 102
1101 1102
102 102
1101 1102
101 101
1101 1102
101 103
1101 1102
101 102
1100 1102
101 102
1102 1102
101 102
1101 1101

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1

result:

ok All testcases passed.

Test #8:

score: 0
Accepted
time: 0ms
memory: 3648kb

input:

10
101 102
1101 1103
998 1000
1999 2000
1000 1000
1999 2000
999 999
1999 2000
999 1001
1999 2000
999 1000
1998 2000
999 1000
2000 2000
999 1000
1999 1999
999 1000
1999 2001
48000 48002
49001 49002

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1

result:

ok All testcases passed.

Test #9:

score: 0
Accepted
time: 0ms
memory: 3692kb

input:

10
48002 48002
49001 49002
48001 48001
49001 49002
48001 48003
49001 49002
48001 48002
49000 49002
48001 48002
49002 49002
48001 48002
49001 49001
48001 48002
49001 49003
48100 48102
49101 49102
48102 48102
49101 49102
48101 48101
49101 49102

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1

result:

ok All testcases passed.

Test #10:

score: 0
Accepted
time: 0ms
memory: 3700kb

input:

10
48101 48103
49101 49102
48101 48102
49100 49102
48101 48102
49102 49102
48101 48102
49101 49101
48101 48102
49101 49103
48998 49000
49999 50000
49000 49000
49999 50000
48999 48999
49999 50000
48999 49001
49999 50000
48999 49000
49998 50000

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1

result:

ok All testcases passed.

Test #11:

score: 0
Accepted
time: 0ms
memory: 3692kb

input:

10
48999 49000
50000 50000
48999 49000
49999 49999
1 2
1001 1002
1001 1002
1 2
2 1
1002 1001
1002 1001
2 1
2 1
1001 1002
1 2
1002 1001
50000 49999
1 2
1 49999
2 50000

output:

-1
-1
100000 1000
-1
-1
-1
-1
-1
-1
-1

result:

ok All testcases passed.

Test #12:

score: 0
Accepted
time: 0ms
memory: 3744kb

input:

10
49997 49998
49999 50000
1 2
49998 49999
1 2
49999 50000
24999 25000
49999 50000
1 2
25001 25002
48001 48002
49001 49002
48101 48102
49101 49102
48999 49000
49999 50000
49993 49994
49998 49999
49992 49993
49997 49998

output:

100000 2
100000 49997
100000 49998
100000 25000
100000 25000
100000 1000
100000 1000
100000 1000
100000 5
100000 5

result:

ok All testcases passed.

Test #13:

score: 0
Accepted
time: 0ms
memory: 3572kb

input:

10
49996 49997
49998 49999
49999 50000
49999 50000
1 3
49999 50000
2 3
49998 50000
1 2
49998 49998
1 2
49999 49999
1 25000
25001 50000
47000 46500
48000 47500
49992 49994
49998 49999
49992 49993
49996 49998

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1

result:

ok All testcases passed.

Extra Test:

score: 0
Extra Test Passed