QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#657711#9485. (mod N² + 1)ucup-team087#AC ✓19ms4104kbC++146.7kb2024-10-19 15:18:022024-10-19 15:18:02

Judging History

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

  • [2024-10-19 15:18:02]
  • 评测
  • 测评结果:AC
  • 用时:19ms
  • 内存:4104kb
  • [2024-10-19 15:18:02]
  • 提交

answer

#include <cassert>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

using Int = long long;

template <class T1, class T2> ostream &operator<<(ostream &os, const pair<T1, T2> &a) { return os << "(" << a.first << ", " << a.second << ")"; };
template <class T> ostream &operator<<(ostream &os, const vector<T> &as) { const int sz = as.size(); os << "["; for (int i = 0; i < sz; ++i) { if (i >= 256) { os << ", ..."; break; } if (i > 0) { os << ", "; } os << as[i]; } return os << "]"; }
template <class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cerr << *i << " "; cerr << endl; }
template <class T> bool chmin(T &t, const T &f) { if (t > f) { t = f; return true; } return false; }
template <class T> bool chmax(T &t, const T &f) { if (t < f) { t = f; return true; } return false; }
#define COLOR(s) ("\x1b[" s "m")

////////////////////////////////////////////////////////////////////////////////
// Barrett
struct ModInt {
  static unsigned M;
  static unsigned long long NEG_INV_M;
  static void setM(unsigned m) { M = m; NEG_INV_M = -1ULL / M; }
  unsigned x;
  ModInt() : x(0U) {}
  ModInt(unsigned x_) : x(x_ % M) {}
  ModInt(unsigned long long x_) : x(x_ % M) {}
  ModInt(int x_) : x(((x_ %= static_cast<int>(M)) < 0) ? (x_ + static_cast<int>(M)) : x_) {}
  ModInt(long long x_) : x(((x_ %= static_cast<long long>(M)) < 0) ? (x_ + static_cast<long long>(M)) : x_) {}
  ModInt &operator+=(const ModInt &a) { x = ((x += a.x) >= M) ? (x - M) : x; return *this; }
  ModInt &operator-=(const ModInt &a) { x = ((x -= a.x) >= M) ? (x + M) : x; return *this; }
  ModInt &operator*=(const ModInt &a) {
    const unsigned long long y = static_cast<unsigned long long>(x) * a.x;
    const unsigned long long q = static_cast<unsigned long long>((static_cast<unsigned __int128>(NEG_INV_M) * y) >> 64);
    const unsigned long long r = y - M * q;
    x = r - M * (r >= M);
    return *this;
  }
  ModInt &operator/=(const ModInt &a) { return (*this *= a.inv()); }
  ModInt pow(long long e) const {
    if (e < 0) return inv().pow(-e);
    ModInt a = *this, b = 1U; for (; e; e >>= 1) { if (e & 1) b *= a; a *= a; } return b;
  }
  ModInt inv() const {
    unsigned a = M, b = x; int y = 0, z = 1;
    for (; b; ) { const unsigned q = a / b; const unsigned c = a - q * b; a = b; b = c; const int w = y - static_cast<int>(q) * z; y = z; z = w; }
    assert(a == 1U); return ModInt(y);
  }
  ModInt operator+() const { return *this; }
  ModInt operator-() const { ModInt a; a.x = x ? (M - x) : 0U; return a; }
  ModInt operator+(const ModInt &a) const { return (ModInt(*this) += a); }
  ModInt operator-(const ModInt &a) const { return (ModInt(*this) -= a); }
  ModInt operator*(const ModInt &a) const { return (ModInt(*this) *= a); }
  ModInt operator/(const ModInt &a) const { return (ModInt(*this) /= a); }
  template <class T> friend ModInt operator+(T a, const ModInt &b) { return (ModInt(a) += b); }
  template <class T> friend ModInt operator-(T a, const ModInt &b) { return (ModInt(a) -= b); }
  template <class T> friend ModInt operator*(T a, const ModInt &b) { return (ModInt(a) *= b); }
  template <class T> friend ModInt operator/(T a, const ModInt &b) { return (ModInt(a) /= b); }
  explicit operator bool() const { return x; }
  bool operator==(const ModInt &a) const { return (x == a.x); }
  bool operator!=(const ModInt &a) const { return (x != a.x); }
  friend std::ostream &operator<<(std::ostream &os, const ModInt &a) { return os << a.x; }
};
unsigned ModInt::M;
unsigned long long ModInt::NEG_INV_M;
// !!!Use ModInt::setM!!!
////////////////////////////////////////////////////////////////////////////////

using Mint = ModInt;

// M: prime
Mint primitiveRoot() {
  const unsigned M = Mint::M;
  vector<unsigned> ds;
  {
    unsigned m = M - 1;
    for (unsigned q = 2; q * q <= m; ++q) if (m % q == 0) {
      do { m /= q; } while (m % q == 0);
      ds.push_back((M - 1) / q);
    }
    if (m > 1) ds.push_back((M - 1) / m);
  }
  for (unsigned a = 1; a < M; ++a) {
    const Mint g = a;
    if ([&]() -> bool {
      for (const unsigned d : ds) if (g.pow(d).x == 1) return false;
      return true;
    }()) {
      return g;
    }
  }
  assert(false);
}


vector<vector<Mint>> solve(int N, int R) {
  const int P = N*N + 1;
  Mint::setM(P);
  
  if (N == 1 && R == 0) return {};
  if (N == 1 && R == 1) return vector<vector<Mint>>{{1}};
  if (N == 3 && R == 0) return vector<vector<Mint>>{{1,2,3},{4,5,6},{7,8,9}};
  for (int d = 2; d < P; ++d) if (P % d == 0) return {};
  assert(N % 2 == 0);
  if (Mint(R).pow(N*N/4) != -1) return {};
  
  const Mint G = primitiveRoot();
  vector<vector<Mint>> a(N, vector<Mint>(N));
  for (int x = 0; x < N; ++x) for (int y = 0; y < N; ++y) {
    int qx = x >> 1, rx = x & 1;
    int qy = y >> 1, ry = y & 1;
    if (ry) qx = N - 1 - qx;
    if (rx) qy = N - 1 - qy;
    a[x][y] = G.pow(qx * (2*N) + qy * 4 + rx * 2 + ry);
  }
  const Mint prod = a[0][0] * a[0][1] * a[1][0] * a[1][1];
  for (int x = 0; x < N - 1; ++x) for (int y = 0; y < N - 1; ++y) {
    assert(prod == a[x][y] * a[x][y + 1] * a[x + 1][y] * a[x + 1][y + 1]);
  }
  for (int c = 1; c < P; ++c) {
    if (prod * Mint(c).pow(4) == R) {
      for (int x = 0; x < N; ++x) for (int y = 0; y < N; ++y) {
        a[x][y] *= c;
      }
      return a;
    }
  }
  assert(false);
}

void stress() {
  for (int N = 1; N <= 50; ++N) {
    vector<int> rs;
    for (int R = 0; R <= N*N; ++R) {
      const auto a = solve(N, R);
      if (a.size()) {
        rs.push_back(R);
        Mint::setM(N*N + 1);
        for (int x = 0; x < N - 1; ++x) for (int y = 0; y < N - 1; ++y) {
          assert(a[x][y] * a[x][y + 1] * a[x + 1][y] * a[x + 1][y + 1] == R);
        }
      }
    }
    cerr << "N = " << N << ": rs = " << rs << endl;
  }
}

int main() {
  // stress();
  
  for (int numCases; ~scanf("%d", &numCases); ) { for (int caseId = 1; caseId <= numCases; ++caseId) {
    int N, R;
    scanf("%d%d", &N, &R);
    
    const auto ans = solve(N, R);
    if (ans.size()) {
      puts("Yes");
      for (int x = 0; x < N; ++x) {
        for (int y = 0; y < N; ++y) {
          if (y) printf(" ");
          printf("%u", ans[x][y].x);
        }
        puts("");
      }
    } else {
      puts("No");
    }
  }
#ifndef LOCAL
  break;
#endif
  }
  return 0;
}

详细

Test #1:

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

input:

3
2 4
3 3
4 2

output:

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

result:

ok Correct Answer

Test #2:

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

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
12 76 192 34 117 150 99 36 8 182 128 154 78 100
140 33 58 39 176 64 11 4 13 148 87 157 67 96
66 175 71 42 151 81 52 114 44 51 113 28 35 54
179 6 122 25 180 137 159 144 170 9 183 136 73 107
166 193 95 133 141 158 89 164 45 63 129 23 94 171
98 19 80 112 5 7 185 62 147 127 120 168 106 109
125 53 30...

result:

ok Correct Answer

Test #3:

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

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
27 190 131 227 74 140 83 32 41 22 237 240 179 165 107 1
209 62 47 207 45 231 229 79 6 185 219 199 155 196 132 215
186 11 160 120 110 211 172 129 54 169 5 68 148 111 166 253
12 9 181 200 53 104 7 198 127 31 138 232 154 244 224 168
82 213 217 34 101 184 214 255 115 95 63 242 220 70 87 16
254 221 1...

result:

ok Correct Answer

Test #4:

score: 0
Accepted
time: 6ms
memory: 3756kb

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
69 389 376 231 381 265 385 212 308 330 86 264 149 131 39 185 352 148 41 359
151 305 289 281 261 251 226 13 82 317 303 296 78 370 298 262 172 127 215 259
113 53 331 283 345 66 276 133 301 347 321 37 337 190 29 152 344 282 195 386
102 23 328 129 9 61 312 377 390 371 287 163 58 304 273 380 241 74 2...

result:

ok Correct Answer

Test #5:

score: 0
Accepted
time: 6ms
memory: 4096kb

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
33 94 430 473 445 201 11 416 528 350 533 67 196 331 176 309 370 407 450 495 251 103 508 328
342 30 512 217 203 281 449 90 382 74 32 266 193 270 569 222 96 221 2 233 553 89 288 86
150 113 276 231 554 125 50 230 92 77 377 234 209 269 223 218 318 78 262 282 459 265 106 26
453 122 334 267 31 258 205...

result:

ok Correct Answer

Test #6:

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

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
56 120 219 566 119 255 550 18 676 288 661 546 421 612 643 314 133 285 97 498 198 521 460 212 590 7
623 658 589 295 333 230 317 99 316 387 189 405 308 660 527 549 583 669 248 338 354 275 276 398 525 448
639 322 69 413 427 515 62 116 315 502 301 585 77 559 555 143 79 257 587 50 591 123 655 614 325...

result:

ok Correct Answer

Test #7:

score: 0
Accepted
time: 13ms
memory: 3760kb

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
272 196 290 428 578 78 447 571 382 335 19 621 304 458 125 558 646 127 181 1 188 16 300 256 61 34
318 488 443 369 70 150 89 94 471 429 241 323 142 401 432 152 27 348 44 191 172 562 180 289 519 145
299 210 45 652 43 277 11 370 176 504 108 617 374 394 568 211 287 668 530 533 356 404 280 371 418 520...

result:

ok Correct Answer

Test #8:

score: 0
Accepted
time: 15ms
memory: 3896kb

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
25 149 976 1044 75 447 334 538 225 44 1002 317 675 132 412 951 728 396 1236 259 887 1188 1114 777 67 970 748 1034 201 316 947 508 603 948 247 227
26 570 200 1192 441 190 499 1262 147 928 1031 853 49 1174 776 1149 881 1256 691 383 726 851 1095 560 242 716 365 619 513 671 554 1071 171 656 617 357
...

result:

ok Correct Answer

Test #9:

score: 0
Accepted
time: 15ms
memory: 3804kb

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
228 10 1171 131 684 30 919 393 755 90 163 1179 968 270 489 943 310 810 170 235 930 1133 510 705 196 805 233 818 588 1118 699 1157 467 760 800 877
289 1048 527 80 961 1214 608 459 1185 837 635 153 395 279 644 51 564 93 647 17 188 31 648 438 495 875 216 146 165 724 72 481 55 1106 24 1025
104 421 1...

result:

ok Correct Answer

Test #10:

score: 0
Accepted
time: 14ms
memory: 3880kb

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
338 925 18 1093 1014 181 54 685 448 543 162 758 47 332 486 977 141 996 161 337 423 394 483 1011 1269 1182 152 439 1213 952 456 20 1045 262 71 60
144 962 110 915 48 753 469 305 16 251 1021 534 870 516 1205 178 290 172 834 924 529 922 278 308 1041 1172 525 535 347 823 175 1043 548 1139 923 780
541...

result:

ok Correct Answer

Test #11:

score: 0
Accepted
time: 19ms
memory: 3788kb

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
261 1194 328 654 952 141 264 214 571 1324 1423 1578 1592 1339 872 1192 188 492 819 1428 698 396 503 56 718 1334 522 787 656 1308 303 282 528 428 1142 1047 1245 1555 1583 1077
1181 1115 232 1595 497 415 1113 1448 666 176 364 101 973 1286 1277 174 1597 773 1344 1235 1499 1300 651 273 601 1130 1391...

result:

ok Correct Answer

Test #12:

score: 0
Accepted
time: 19ms
memory: 3848kb

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
71 288 948 914 1541 388 1544 1009 186 78 657 1515 384 1039 685 907 1051 1422 278 1511 104 715 419 279 318 185 142 576 295 227 1481 776 1487 417 372 156 1314 1429 768 477
309 1524 241 256 675 438 542 124 402 1563 1013 1561 645 632 1016 581 1238 106 292 1207 1150 1102 1042 1160 507 884 955 762 921...

result:

ok Correct Answer

Test #13:

score: 0
Accepted
time: 19ms
memory: 4104kb

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
541 1518 594 1282 84 1378 400 1149 380 211 361 1081 423 1107 642 11 770 891 1532 126 815 600 374 570 1476 1342 1082 1435 1188 963 168 1155 800 697 760 422 722 561 846 613
528 428 303 282 656 1308 522 787 718 1334 503 56 698 396 819 1428 188 492 872 1192 1592 1339 1423 1578 571 1324 264 214 952 1...

result:

ok Correct Answer

Test #14:

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

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
621 467 670 1004 1437 1274 1125 730 1469 1494 515 939 89 812 805 131 1165 1005 1507 1355 391 887 1252 1403 549 1573 1242 934 1340 407 1273 947 649 1460 1337 1387 1030 277 178 23
1485 3 552 593 244 877 1268 1513 1419 750 314 958 162 1514 2 414 929 183 51 951 475 664 500 1036 105 922 1543 802 276 ...

result:

ok Correct Answer

Test #15:

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

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: 3968kb

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: 3676kb

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: 0ms
memory: 3748kb

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: 3692kb

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: 0ms
memory: 3628kb

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: 3740kb

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: 0ms
memory: 3740kb

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: 0ms
memory: 3932kb

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: 3748kb

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: 3888kb

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
1 2
4 3
Yes
1 2 3
4 5 6
7 8 9
No
No
No
No
No
No
No
No
No
No
No
Yes
1 14 13 12
2 11 8 10
16 3 4 5
15 6 9 7
No
No
No
No
No
Yes
6 16 10 4
12 15 14 9
11 1 7 13
5 2 3 8
Yes
3 8 5 2
6 16 7 13
14 9 12 15
11 1 10 4
No
No
No
No
No
Yes
2 11 9 7
4 5 16 3
15 6 8 10
13 12 1 14
No
No
No
No
No
No
N...

result:

ok Correct Answer

Test #26:

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

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: 3868kb

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
13 63 6 ...

result:

ok Correct Answer

Test #28:

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

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

result:

ok Correct Answer

Extra Test:

score: 0
Extra Test Passed