QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#671053#9485. (mod N² + 1)ucup-team4435AC ✓10ms3844kbC++238.9kb2024-10-24 10:29:202024-10-24 10:29:21

Judging History

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

  • [2024-10-24 10:29:21]
  • 评测
  • 测评结果:AC
  • 用时:10ms
  • 内存:3844kb
  • [2024-10-24 10:29:20]
  • 提交

answer

#pragma GCC optimize("Ofast")

#include "bits/stdc++.h"

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
#define rep1n(i, n) for (int i = 1; i <= (n); ++i)
#define repr(i, n) for (int i = (n) - 1; i >= 0; --i)
#define pb push_back
#define eb emplace_back
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define each(x, a) for (auto &x : a)
#define ar array
#define vec vector
#define range(i, n) rep(i, n)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using str = string;
using pi = pair<int, int>;
using pl = pair<ll, ll>;

using vi = vector<int>;
using vl = vector<ll>;
using vpi = vector<pair<int, int>>;
using vvi = vector<vi>;

int Bit(int mask, int b) { return (mask >> b) & 1; }

template<class T>
bool ckmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
bool ckmax(T &a, const T &b) {
    if (b > a) {
        a = b;
        return true;
    }
    return false;
}

// [l, r)
template<typename T, typename F>
T FindFirstTrue(T l, T r, const F &predicat) {
    --l;
    while (r - l > 1) {
        T mid = l + (r - l) / 2;
        if (predicat(mid)) {
            r = mid;
        } else {
            l = mid;
        }
    }
    return r;
}


template<typename T, typename F>
T FindLastFalse(T l, T r, const F &predicat) {
    return FindFirstTrue(l, r, predicat) - 1;
}


const ll INF = 2e18;
const int INFi = 2e9;
const int N = 5e5 + 5;
const int LG = 20;

// MOD assumed to be prime

template<typename T>
int normalize(T value, int mod) {
    if (value < -mod || value >= 2 * mod)
        value %= mod;

    if (value < 0)
        value += mod;

    if (value >= mod)
        value -= mod;

    return value;
}

template<typename T>
struct dynamic_modular_int {
    using mint = dynamic_modular_int<T>;

    int value;

    dynamic_modular_int() : value(0) {}
    dynamic_modular_int(const mint &x) : value(x.value) {}

    template<typename U, typename V = std::enable_if_t<std::is_integral<U>::value>>
    dynamic_modular_int(U value) : value(normalize(value, T::mod)) {}

    template<typename U>
    mint power(U degree) const {
        mint prod = 1;
        mint a = *this;

        for (; degree > 0; degree >>= 1, a *= a)
            if (degree & 1)
                prod *= a;

        return prod;
    }

    mint inv() const {
        return power(T::mod - 2);
    }

    mint& operator=(const mint &x) {
        value = x.value;
        return *this;
    }

    mint& operator+=(const mint &x) {
        value += x.value;
        if (value >= T::mod)
            value -= T::mod;

        return *this;
    }

    mint& operator-=(const mint &x) {
        value -= x.value;
        if (value < 0)
            value += T::mod;

        return *this;
    }

    mint& operator*=(const mint &x) {
        value = (long long) value * x.value % T::mod;
        return *this;
    }

    mint& operator/=(const mint &x) {
        return *this *= x.inv();
    }

    friend mint operator+(const mint &x, const mint &y) {
        return mint(x) += y;
    }

    friend mint operator-(const mint &x, const mint &y) {
        return mint(x) -= y;
    }

    friend mint operator*(const mint &x, const mint &y) {
        return mint(x) *= y;
    }

    friend mint operator/(const mint &x, const mint &y) {
        return mint(x) /= y;
    }

    mint& operator++() {
        ++value;
        if (value == T::mod)
            value = 0;

        return *this;
    }

    mint& operator--() {
        --value;
        if (value == -1)
            value = T::mod - 1;

        return *this;
    }

    mint operator++(int) {
        mint prev = *this;
        value++;
        if (value == T::mod)
            value = 0;

        return prev;
    }

    mint operator--(int) {
        mint prev = *this;
        value--;
        if (value == -1)
            value = T::mod - 1;

        return prev;
    }

    mint operator-() const {
        return mint(0) - *this;
    }

    bool operator==(const mint &x) const {
        return value == x.value;
    }

    bool operator!=(const mint &x) const {
        return value != x.value;
    }

    template<typename U>
    explicit operator U() {
        return value;
    }

    friend std::istream& operator>>(std::istream &in, mint &x) {
        std::string s;
        in >> s;
        x = 0;
        for (const auto c : s)
            x = x * 10 + (c - '0');

        return in;
    }

    friend std::ostream& operator<<(std::ostream &out, const mint &x) {
        return out << x.value;
    }

    static int primitive_root() {
        int root = -1;

        std::vector<int> primes;
        int value = T::mod - 1;
        for (int i = 2; i * i <= value; i++)
            if (value % i == 0) {
                primes.push_back(i);
                while (value % i == 0)
                    value /= i;
            }

        if (value != 1)
            primes.push_back(value);

        for (int r = 2;; r++) {
            bool ok = true;
            for (auto p : primes)
                if ((mint(r).power((T::mod - 1) / p)).value == 1) {
                    ok = false;
                    break;
                }

            if (ok)
                return root = r;
        }
    }
};

struct dynamic_modular_int_mod {
    static int mod;
};

int dynamic_modular_int_mod::mod = 998244353;
int &MOD = dynamic_modular_int_mod::mod;

using mint = dynamic_modular_int<dynamic_modular_int_mod>;


void solve(int n, int r) {
    if (n == 3 && r == 0) {
        cout << "Yes\n";
        cout << "3 6 1\n";
        cout << "2 5 4\n";
        cout << "7 8 9\n";
        return;
    }
    int who = n * n + 1;
    for(int x = 2; x * x <= who; ++x) {
        if (who % x == 0) {
            cout << "No\n";
            return;
        }
    }

    if (!r) {
        cout << "No\n";
        return;
    }

    MOD = who;

    vector<int> a(who, -1);

    int md2 = n * n;
    {
        int root = mint::primitive_root();
        mint cur = 1;
        for (int i = 0; i < md2; ++i) {
            a[cur.value] = i;
            cur *= root;
        }
    }

    vector<int> b(md2, 0);
    for(int i = 1; i < who; ++i) b[a[i]] = i;

    vector<vi> ans(n, vi(n));
    int start = md2 - 1;
    for(int i = 0; i < n; i += 2) {
        for(int j = 0; j < n; j += 2) {
            ans[i][j] = start;
            start--;
        }
    }

    for(int i = n - 2; i >= 0; i -= 2) {
        for(int j = n - 1; j >= 0; j -= 2) {
            ans[i][j] = start;
            start--;
        }
    }


    for(int i = 1; i < n; i += 2) {
        for(int j = n - 2; j >= 0; j -= 2) {
            ans[i][j] = start;
            start--;
        }
    }

    for(int i = n - 1; i >= 0; i -= 2) {
        for(int j = 1; j < n; j += 2) {
            ans[i][j] = start;
            start--;
        }
    }
    assert(start == -1);

//    rep(i, n ){
//        rep(j, n) {
//            int x; cin >> x;
//            cout << a[x] << ' ';
//        }
//        cout << '\n';
//    }

    // r * (n^2/4) == (n^2) * (n^2-1) / 2
    // 13 * 4 == 8 * 15
//    vi kek;
//    sort(all(kek));
//    assert(kek[0] == kek.back());

    bool ok = false;
    int rr = a[r];
//    cerr << a[2] << '\n';
    rep(add, n * n) {
        int cur = (ans[0][0] + ans[1][1] + ans[0][1] + ans[1][0] + add * 4) % md2;
//        cerr << (rr * (n * n / 4)) % (n * n) << ' ' << (cur * (n * n / 4)) % (n * n) << endl;
        if (cur != rr) continue;
        ok = true;
        rep(i, n) {
            rep(j, n) {
                ans[i][j] = (ans[i][j] + add) % md2;
            }
        }
    }
    if (!ok) {
        cout << "No\n";
        return;
    }

    vector<vector<mint>> res(n, vector<mint>(n));
    rep(i, n) {
        rep(j, n) {
            res[i][j] = b[ans[i][j]];
        }
    }
    assert(mint(r) == res[0][0] * res[0][1] * res[1][1] * res[1][0]);
    cout << "Yes\n";
    rep(i, n) {
        rep(j, n) {
            cout << res[i][j] << ' ';
        }
        cout << '\n';
    }
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(12) << fixed;
    int t = 1;

//    for(int q = 2; q <= 50; ++q) {
//        int cnt = (q / 2) * (q / 2);
//        int pr = 5;
//        int need = q * q + 1;
//        while (pr < need && need % pr != 0) pr++;
//        if (pr < need && (need - 1) / pr >= cnt) {
//            cerr << q << endl;
//        }
//    }
    cin >> t;
    rep(i, t) {
        int n, r; cin >> n >> r;
        solve(n, r);
    }
//    for(int n = 2; n <= 50; ++n) {
//        solve(n, 1);
//    }
    return 0;
}

详细

Test #1:

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

input:

3
2 4
3 3
4 2

output:

Yes
2 1 
3 4 
No
Yes
11 1 15 3 
2 14 6 16 
5 9 13 10 
4 7 12 8 

result:

ok Correct Answer

Test #2:

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

input:

100
14 4
14 6
14 7
14 9
14 10
14 15
14 19
14 22
14 25
14 26
14 33
14 39
14 41
14 43
14 47
14 55
14 62
14 64
14 65
14 83
14 92
14 93
14 96
14 97
14 107
14 109
14 112
14 116
14 121
14 127
14 134
14 136
14 137
14 138
14 143
14 144
14 146
14 148
14 155
14 157
14 160
14 161
14 163
14 168
14 169
14 173
14...

output:

Yes
196 2 98 4 49 8 123 16 160 32 80 64 40 128 
157 69 117 133 37 165 74 181 148 189 99 193 1 195 
20 59 10 118 5 39 101 78 149 156 173 115 185 33 
12 164 24 82 48 41 96 119 192 158 187 79 177 138 
191 66 194 132 97 67 147 134 172 71 86 142 43 87 
154 110 111 55 25 126 50 63 100 130 3 65 6 131 
120 ...

result:

ok Correct Answer

Test #3:

score: 0
Accepted
time: 3ms
memory: 3828kb

input:

100
16 205
16 207
16 208
16 215
16 221
16 226
16 228
16 231
16 232
16 236
16 239
16 244
16 248
20 2
20 7
20 8
20 9
20 10
20 11
20 28
20 32
20 35
20 36
20 40
20 43
20 44
20 45
20 47
20 50
20 55
20 58
20 73
20 78
20 82
20 89
20 98
20 102
20 103
20 109
20 111
20 112
20 114
20 126
20 128
20 138
20 140
2...

output:

Yes
72 41 24 123 8 112 174 79 58 237 105 197 35 77 183 231 
74 26 222 180 152 60 199 20 83 178 249 145 233 134 185 216 
61 179 106 23 121 69 126 207 42 107 14 64 176 192 230 62 
27 195 81 65 243 193 215 150 131 50 136 188 151 234 196 78 
248 186 254 44 256 132 171 139 57 160 19 223 92 155 202 208 
5...

result:

ok Correct Answer

Test #4:

score: 0
Accepted
time: 3ms
memory: 3828kb

input:

100
20 357
20 358
20 361
20 365
20 366
20 369
20 373
20 390
20 391
20 392
20 393
20 394
20 399
24 11
24 17
24 22
24 23
24 25
24 33
24 34
24 35
24 44
24 46
24 49
24 50
24 51
24 53
24 59
24 66
24 68
24 69
24 70
24 75
24 88
24 92
24 98
24 99
24 100
24 102
24 105
24 106
24 118
24 127
24 131
24 132
24 13...

output:

Yes
95 116 299 348 367 242 256 325 219 173 73 118 158 354 320 260 374 379 392 335 
9 66 27 22 81 141 243 47 328 283 182 228 145 76 34 159 102 53 306 285 
398 203 400 208 267 223 89 268 297 2 99 6 33 18 11 54 271 162 224 85 
177 316 130 239 390 347 368 383 302 395 104 399 312 133 134 178 1 193 3 198 ...

result:

ok Correct Answer

Test #5:

score: 0
Accepted
time: 4ms
memory: 3752kb

input:

100
24 354
24 362
24 365
24 367
24 368
24 370
24 373
24 377
24 379
24 381
24 392
24 393
24 396
24 400
24 401
24 408
24 414
24 418
24 420
24 424
24 427
24 430
24 437
24 439
24 441
24 445
24 446
24 450
24 459
24 471
24 472
24 475
24 477
24 478
24 479
24 485
24 489
24 502
24 507
24 508
24 509
24 511
24...

output:

Yes
307 196 523 403 220 284 44 266 355 176 71 303 245 361 49 74 356 370 302 119 522 18 566 90 
11 487 55 559 275 458 221 207 528 503 332 216 506 274 222 401 533 311 357 293 54 174 270 381 
344 450 415 519 83 287 132 281 488 251 213 101 158 505 147 217 491 508 329 232 412 6 544 30 
33 547 165 571 248...

result:

ok Correct Answer

Test #6:

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

input:

100
26 152
26 155
26 157
26 160
26 161
26 163
26 164
26 167
26 173
26 178
26 183
26 184
26 187
26 191
26 193
26 198
26 201
26 209
26 218
26 219
26 220
26 222
26 223
26 235
26 236
26 249
26 251
26 253
26 262
26 265
26 273
26 283
26 284
26 289
26 294
26 301
26 306
26 307
26 312
26 315
26 323
26 324
26...

output:

Yes
165 347 421 17 549 34 613 68 645 136 661 272 669 544 673 411 675 145 676 290 338 580 169 483 423 289 
254 388 508 194 339 97 1 387 2 532 4 266 8 133 16 405 32 541 64 609 128 643 256 660 512 330 
550 578 275 479 476 281 238 562 119 447 398 217 199 434 438 191 219 382 448 87 224 174 112 348 56 19 ...

result:

ok Correct Answer

Test #7:

score: 0
Accepted
time: 3ms
memory: 3568kb

input:

100
26 582
26 584
26 587
26 590
26 591
26 592
26 593
26 596
26 599
26 606
26 618
26 622
26 631
26 636
26 637
26 639
26 641
26 642
26 643
26 655
26 661
26 662
26 663
26 664
26 671
26 676
36 2
36 6
36 7
36 8
36 13
36 18
36 21
36 24
36 25
36 28
36 32
36 38
36 39
36 46
36 47
36 52
36 54
36 55
36 61
36 6...

output:

Yes
69 539 373 401 525 125 601 250 639 500 658 323 329 646 503 615 590 553 295 429 486 181 243 362 460 47 
217 630 434 315 191 496 382 248 87 124 174 62 348 31 19 354 38 177 76 427 152 552 304 276 608 138 
230 94 115 188 396 376 198 75 99 150 388 300 194 600 97 523 387 369 532 61 266 122 133 244 405...

result:

ok Correct Answer

Test #8:

score: 0
Accepted
time: 8ms
memory: 3552kb

input:

100
36 289
36 291
36 294
36 295
36 299
36 300
36 303
36 309
36 318
36 319
36 321
36 326
36 334
36 336
36 338
36 340
36 341
36 342
36 343
36 350
36 351
36 359
36 363
36 370
36 371
36 384
36 386
36 388
36 392
36 395
36 397
36 398
36 399
36 400
36 404
36 410
36 412
36 414
36 415
36 417
36 423
36 424
36...

output:

Yes
479 398 437 89 1211 890 1029 1118 492 804 568 258 835 1283 732 1157 592 1194 578 267 836 76 343 760 164 1115 1054 774 1143 1255 244 877 1062 988 625 801 
672 496 235 309 1053 420 154 42 243 523 1133 182 954 537 461 1221 719 1030 705 103 565 140 462 14 729 1039 805 493 268 179 86 407 860 1208 818...

result:

ok Correct Answer

Test #9:

score: 0
Accepted
time: 7ms
memory: 3512kb

input:

100
36 717
36 722
36 728
36 730
36 732
36 733
36 734
36 736
36 741
36 745
36 748
36 751
36 752
36 756
36 765
36 770
36 785
36 802
36 804
36 811
36 813
36 814
36 822
36 829
36 831
36 832
36 841
36 849
36 852
36 854
36 862
36 864
36 867
36 869
36 873
36 874
36 880
36 882
36 883
36 885
36 887
36 893
36...

output:

Yes
1280 170 128 403 791 139 987 93 1266 930 386 221 298 913 808 51 859 510 475 1209 696 417 329 279 422 196 561 663 964 145 1134 153 1151 233 1023 1033 
274 264 146 1064 163 1144 333 1152 736 634 875 1101 968 1018 601 880 822 88 438 787 489 1246 999 384 911 1076 31 367 310 1204 506 1158 1169 894 17...

result:

ok Correct Answer

Test #10:

score: 0
Accepted
time: 5ms
memory: 3620kb

input:

100
36 1132
36 1135
36 1136
36 1141
36 1142
36 1145
36 1152
36 1156
36 1158
36 1159
36 1164
36 1169
36 1176
36 1180
36 1183
36 1185
36 1190
36 1191
36 1194
36 1196
36 1197
36 1199
36 1200
36 1201
36 1212
36 1213
36 1222
36 1225
36 1226
36 1230
36 1234
36 1236
36 1242
36 1243
36 1245
36 1250
36 1251
...

output:

Yes
458 608 824 892 1120 1138 112 1004 530 961 53 531 135 122 662 1220 585 527 707 82 1238 820 902 418 609 289 450 296 45 366 653 1066 195 284 668 246 
629 1051 1102 1013 644 231 1252 931 847 1001 688 1008 395 879 59 477 590 1215 712 770 635 77 1162 1175 1244 766 767 336 1185 293 177 159 473 405 839...

result:

ok Correct Answer

Test #11:

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

input:

100
40 205
40 206
40 213
40 215
40 218
40 225
40 227
40 233
40 235
40 238
40 242
40 245
40 249
40 261
40 263
40 264
40 268
40 279
40 281
40 286
40 288
40 289
40 296
40 303
40 307
40 312
40 313
40 322
40 328
40 330
40 335
40 338
40 339
40 342
40 344
40 347
40 349
40 353
40 354
40 356
40 358
40 359
40...

output:

Yes
1300 903 967 1108 856 122 819 366 273 1098 91 92 564 276 188 828 1130 883 1444 1048 1015 1543 872 1427 1358 1079 1520 35 1574 105 1592 315 1598 945 1600 1234 1067 500 1423 1500 
178 101 534 1101 1 367 3 656 9 1286 27 1496 81 1566 243 522 729 174 586 58 157 553 471 718 1413 773 1037 1325 1510 150...

result:

ok Correct Answer

Test #12:

score: 0
Accepted
time: 10ms
memory: 3660kb

input:

100
40 621
40 624
40 626
40 627
40 631
40 633
40 644
40 647
40 649
40 656
40 660
40 661
40 669
40 670
40 676
40 678
40 683
40 684
40 687
40 688
40 693
40 694
40 698
40 701
40 703
40 706
40 708
40 711
40 712
40 715
40 716
40 718
40 720
40 729
40 740
40 741
40 746
40 749
40 752
40 756
40 767
40 776
40...

output:

Yes
499 104 700 312 767 936 1323 1207 441 419 147 1257 49 569 550 106 717 318 239 954 1147 1261 916 581 839 142 1347 426 449 1278 1217 632 1473 295 491 885 1231 1054 944 1561 
657 40 370 547 1110 716 128 1306 384 969 1152 323 254 1175 762 1459 685 1020 454 340 1362 647 884 1283 1051 1495 1552 1032 1...

result:

ok Correct Answer

Test #13:

score: 0
Accepted
time: 9ms
memory: 3636kb

input:

100
40 987
40 995
40 996
40 1006
40 1009
40 1022
40 1023
40 1025
40 1029
40 1030
40 1039
40 1043
40 1044
40 1052
40 1056
40 1058
40 1065
40 1072
40 1073
40 1075
40 1079
40 1086
40 1090
40 1098
40 1103
40 1111
40 1114
40 1116
40 1117
40 1124
40 1125
40 1131
40 1135
40 1142
40 1144
40 1147
40 1151
40 ...

output:

Yes
874 580 825 139 275 417 1159 1251 920 551 1374 52 458 156 1220 468 1474 1404 1025 1010 1409 1429 1537 1085 1046 53 1416 159 472 477 691 1431 764 1091 1322 71 1508 213 1570 639 
31 962 93 1388 279 1530 837 510 910 170 1129 1124 185 1442 555 1548 64 516 192 172 576 591 127 197 381 1133 1143 1445 2...

result:

ok Correct Answer

Test #14:

score: 0
Accepted
time: 5ms
memory: 3844kb

input:

50
40 1402
40 1405
40 1406
40 1407
40 1412
40 1413
40 1416
40 1421
40 1422
40 1423
40 1424
40 1429
40 1430
40 1432
40 1436
40 1437
40 1440
40 1445
40 1453
40 1457
40 1458
40 1467
40 1469
40 1480
40 1482
40 1492
40 1498
40 1503
40 1504
40 1507
40 1511
40 1512
40 1515
40 1519
40 1523
40 1527
40 1529
4...

output:

Yes
944 370 1382 1110 1528 128 1043 384 1415 1152 1539 254 513 762 171 685 57 454 19 1362 540 884 180 1051 60 1552 20 1454 1074 1160 358 278 653 834 1285 901 962 1102 1388 104 
213 1497 639 499 316 700 948 767 1243 1323 527 441 1581 147 1541 49 1421 550 1061 717 1582 239 1544 1147 1430 916 1088 839 ...

result:

ok Correct Answer

Test #15:

score: 0
Accepted
time: 1ms
memory: 3628kb

input:

100
34 125
49 1179
48 1952
25 454
34 988
42 1332
46 283
22 384
39 1024
49 1642
23 175
30 493
34 630
40 23
47 698
49 1993
30 187
38 1114
46 464
35 1168
29 751
46 876
49 2314
44 135
35 178
44 85
43 844
31 340
32 270
33 328
23 286
32 404
45 1899
31 823
36 668
25 304
37 1015
37 286
46 795
49 208
26 210
...

output:

No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No

result:

ok Correct Answer

Test #16:

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

input:

100
29 518
21 5
48 1239
35 317
46 938
37 538
50 1355
31 160
50 453
44 1131
29 483
47 1150
39 625
47 2183
44 867
37 615
31 385
42 1140
43 203
37 10
19 323
49 2235
32 825
48 740
17 125
49 287
36 776
35 124
37 635
45 597
19 310
32 971
39 78
31 33
50 1384
50 516
36 1017
49 1406
15 8
18 74
19 264
30 171
...

output:

No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No

result:

ok Correct Answer

Test #17:

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

input:

100
28 111
50 1695
46 1525
48 850
32 420
45 1009
39 551
41 1629
28 598
42 230
47 416
28 180
31 954
19 7
45 1480
19 26
28 561
42 889
30 196
50 831
44 155
41 1246
49 916
47 1579
37 846
16 156
44 1154
39 1389
49 1020
45 669
48 354
38 1207
43 166
50 1937
34 54
38 1067
39 518
47 112
24 290
46 1107
40 73
...

output:

No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No

result:

ok Correct Answer

Test #18:

score: 0
Accepted
time: 1ms
memory: 3836kb

input:

100
37 1332
50 1537
30 66
47 1228
49 1035
25 77
44 1193
20 37
42 171
21 50
42 375
50 2175
50 1926
41 640
49 788
31 16
45 1662
35 207
16 189
15 57
21 420
49 2095
32 1003
39 253
32 326
16 241
40 935
41 479
47 1419
42 1578
31 316
45 761
36 535
43 1251
49 175
46 1537
25 384
28 161
47 1820
11 38
40 128
3...

output:

No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No

result:

ok Correct Answer

Test #19:

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

input:

100
47 1092
45 1000
46 1426
46 805
41 465
45 1964
36 562
39 1271
43 1079
39 671
36 212
48 534
49 1307
34 616
22 266
31 323
33 822
45 1025
38 681
31 637
49 169
50 2321
35 683
17 151
34 458
49 270
30 774
48 77
36 760
25 279
49 738
17 236
45 374
17 32
44 573
46 1195
39 194
37 997
47 1093
48 780
35 886
...

output:

No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No

result:

ok Correct Answer

Test #20:

score: 0
Accepted
time: 1ms
memory: 3800kb

input:

100
47 2144
37 1205
41 680
39 228
48 2238
26 412
50 1573
39 215
49 576
34 750
24 452
47 1152
36 1253
50 1699
48 2004
48 1544
37 556
21 348
49 1528
49 2210
44 129
41 558
25 100
46 1151
23 1
43 1815
34 1084
31 869
13 1
47 1238
41 1413
41 815
46 1255
18 44
24 474
43 1363
50 544
39 51
45 1608
40 252
34 ...

output:

No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No

result:

ok Correct Answer

Test #21:

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

input:

100
40 809
46 1371
39 602
27 655
50 810
33 907
40 181
46 58
33 87
37 1312
49 1266
37 1213
50 861
30 782
47 1611
43 1033
37 641
48 1797
39 345
35 158
27 179
46 1699
45 628
50 2326
31 91
49 1600
28 422
30 222
27 583
44 271
39 889
41 105
44 67
38 387
49 1011
45 1249
42 1621
41 416
20 18
45 1891
18 263
...

output:

No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No

result:

ok Correct Answer

Test #22:

score: 0
Accepted
time: 1ms
memory: 3764kb

input:

100
32 716
43 483
17 23
32 587
19 184
33 913
44 1369
49 404
48 1878
40 1035
45 1968
29 457
46 2078
49 1404
19 41
44 224
40 1046
45 90
33 300
38 1125
49 1652
29 427
45 468
49 744
48 1720
16 235
44 877
44 538
24 559
20 260
45 159
49 1729
20 62
35 1023
15 203
38 1273
50 2479
35 244
29 550
31 687
45 197...

output:

No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No

result:

ok Correct Answer

Test #23:

score: 0
Accepted
time: 1ms
memory: 3832kb

input:

100
38 470
46 1899
13 123
41 1132
38 1414
34 1021
33 212
40 1078
48 343
30 476
47 796
30 490
35 150
44 1247
19 177
38 205
33 628
40 544
21 87
44 814
49 1216
44 1767
20 13
34 887
42 1372
17 101
50 1277
13 148
44 960
21 261
48 1293
50 1881
45 1710
47 382
20 179
40 1314
30 369
37 1329
39 541
29 535
42 ...

output:

No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No

result:

ok Correct Answer

Test #24:

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

input:

100
48 1753
31 279
48 1177
50 1524
41 1180
42 218
41 1170
50 1176
49 1071
12 117
27 369
47 832
28 274
29 766
38 1117
49 775
49 1134
31 163
50 1593
47 529
36 1097
35 176
30 19
45 447
48 1888
15 184
41 716
13 25
43 1695
40 76
46 1008
47 1467
28 609
44 380
36 324
38 186
48 2084
46 1718
48 2096
41 261
4...

output:

No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No

result:

ok Correct Answer

Test #25:

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

input:

100
2 0
2 1
2 2
2 3
2 4
3 0
3 1
3 2
3 3
3 4
3 5
3 6
3 7
3 8
3 9
4 0
4 1
4 2
4 3
4 4
4 5
4 6
4 7
4 8
4 9
4 10
4 11
4 12
4 13
4 14
4 15
4 16
5 0
5 1
5 2
5 3
5 4
5 5
5 6
5 7
5 8
5 9
5 10
5 11
5 12
5 13
5 14
5 15
5 16
5 17
5 18
5 19
5 20
5 21
5 22
5 23
5 24
5 25
6 0
6 1
6 2
6 3
6 4
6 5
6 6
6 7
6 8
6 9
6...

output:

No
No
No
No
Yes
2 1 
3 4 
Yes
3 6 1
2 5 4
7 8 9
No
No
No
No
No
No
No
No
No
No
No
Yes
11 1 15 3 
2 14 6 16 
5 9 13 10 
4 7 12 8 
No
No
No
No
No
Yes
8 10 14 13 
3 4 9 7 
16 5 11 15 
6 2 1 12 
Yes
16 3 11 9 
6 8 1 14 
15 10 5 13 
12 4 2 7 
No
No
No
No
No
Yes
14 9 16 10 
1 7 3 8 
11 13 15 5 
2 12 6 4 
N...

result:

ok Correct Answer

Test #26:

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

input:

100
7 5
7 6
7 7
7 8
7 9
7 10
7 11
7 12
7 13
7 14
7 15
7 16
7 17
7 18
7 19
7 20
7 21
7 22
7 23
7 24
7 25
7 26
7 27
7 28
7 29
7 30
7 31
7 32
7 33
7 34
7 35
7 36
7 37
7 38
7 39
7 40
7 41
7 42
7 43
7 44
7 45
7 46
7 47
7 48
7 49
8 0
8 1
8 2
8 3
8 4
8 5
8 6
8 7
8 8
8 9
8 10
8 11
8 12
8 13
8 14
8 15
8 16
8...

output:

No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No

result:

ok Correct Answer

Test #27:

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

input:

100
8 55
8 56
8 57
8 58
8 59
8 60
8 61
8 62
8 63
8 64
9 0
9 1
9 2
9 3
9 4
9 5
9 6
9 7
9 8
9 9
9 10
9 11
9 12
9 13
9 14
9 15
9 16
9 17
9 18
9 19
9 20
9 21
9 22
9 23
9 24
9 25
9 26
9 27
9 28
9 29
9 30
9 31
9 32
9 33
9 34
9 35
9 36
9 37
9 38
9 39
9 40
9 41
9 42
9 43
9 44
9 45
9 46
9 47
9 48
9 49
9 50
9...

output:

No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
Yes
100 2 50...

result:

ok Correct Answer

Test #28:

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

input:

93
10 8
10 9
10 10
10 11
10 12
10 13
10 14
10 15
10 16
10 17
10 18
10 19
10 20
10 21
10 22
10 23
10 24
10 25
10 26
10 27
10 28
10 29
10 30
10 31
10 32
10 33
10 34
10 35
10 36
10 37
10 38
10 39
10 40
10 41
10 42
10 43
10 44
10 45
10 46
10 47
10 48
10 49
10 50
10 51
10 52
10 53
10 54
10 55
10 56
10 57...

output:

No
Yes
94 14 47 28 74 56 37 11 69 22 
32 79 64 90 27 45 54 73 7 87 
85 44 93 88 97 75 99 49 100 98 
1 3 2 52 4 26 8 13 16 57 
50 95 25 89 63 77 82 53 41 5 
60 96 19 48 38 24 76 12 51 6 
71 10 86 20 43 40 72 80 36 59 
65 42 29 21 58 61 15 81 30 91 
18 17 9 34 55 68 78 35 39 70 
62 31 23 66 46 33 92 6...

result:

ok Correct Answer

Extra Test:

score: 0
Extra Test Passed