QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#137423#2353. Maharajas are Going Home4k2kok#WA 1ms3464kbC++2031.0kb2023-08-10 12:27:342023-08-10 12:28:07

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-08-10 12:28:07]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3464kb
  • [2023-08-10 12:27:34]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define INF 0x3f3f3f3f
#define PI acos(-1)
#define io ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define mem(a,b) memset((a),(b),sizeof(a))
typedef long long ll;
typedef unsigned long long ull;
#define int long long
#define db long double

const double eps = 1e-6;
const int mod = 1e9 + 7;
const int maxn = 1e5 + 10;

int a[5200], x[5200], y[5200], k;

void solve() {
    cin >> k;
    int ans = 0;
    for (int i = 1; i <= k; i++) {
        cin >> x[i] >> y[i];
        if (a[x[i]] == y[i]) ans ^= 0;
        else ans ^= 1;
    }
    if (ans == 0) {
        cout << "-1 -1 -1\n";
    } else {
        for(int z = 1; z <= k; z++) {
            int i = x[z], j = y[z];
            int tmpi = i, tmpj = j - 1, tmp = ans;
            while(tmpj > 0) {
                tmp ^= (!(a[i] == j));
                tmp ^= (!(a[tmpi] == tmpj));
                if(tmp == 0) {
                    cout << z << ' ' << tmpi << ' ' << tmpj << '\n';
                    return;
                }
                tmpj--;
            }
            tmpi = i - 1, tmpj = j, tmp = ans;
            while(tmpi > 0) {
                tmp ^= (!(a[i] == j));
                tmp ^= (!(a[tmpi] == tmpj));
                if(tmp == 0) {
                    cout << z << ' ' << tmpi << ' ' << tmpj << '\n';
                    return;
                }
                tmpi--;
            }
            tmpi = i - 1, tmpj = j - 1, tmp = ans;
            while(tmpi > 0 && tmpj > 0) {
                tmp ^= (!(a[i] == j));
                tmp ^= (!(a[tmpi] == tmpj));
                if(tmp == 0) {
                    cout << z << ' ' << tmpi << ' ' << tmpj << '\n';
                    return;
                }
                tmpi--, tmpj--;
            }
            tmpi = i - 2, tmpj = j - 1, tmp = ans;
            while(tmpi > 0 && tmpj > 0) {
                tmp ^= (!(a[i] == j));
                tmp ^= (!(a[tmpi] == tmpj));
                if(tmp == 0) {
                    cout << z << ' ' << tmpi << ' ' << tmpj << '\n';
                    return;
                }
                tmpi -= 2, tmpj--;
            }
            tmpi = i - 1, tmpj = j - 2, tmp = ans;
            while(tmpi > 0 && tmpj > 0) {
                tmp ^= (!(a[i] == j));
                tmp ^= (!(a[tmpi] == tmpj));
                if(tmp == 0) {
                    cout << z << ' ' << tmpi << ' ' << tmpj << '\n';
                    return;
                }
                tmpi--, tmpj -= 2;
            }
        }
    }

}

signed main(){
    io;
    int T = 1;
    a[1] = 1;
    a[2] = 4;
    a[3] = 7;
    a[4] = 2;
    a[5] = 6;
    a[6] = 5;
    a[7] = 3;
    a[8] = 11;
    a[9] = 15;
    a[10] = 18;
    a[11] = 8;
    a[12] = 26;
    a[13] = 29;
    a[14] = 19;
    a[15] = 9;
    a[16] = 36;
    a[17] = 24;
    a[18] = 10;
    a[19] = 14;
    a[20] = 32;
    a[21] = 30;
    a[22] = 49;
    a[23] = 33;
    a[24] = 17;
    a[25] = 56;
    a[26] = 12;
    a[27] = 38;
    a[28] = 41;
    a[29] = 13;
    a[30] = 21;
    a[31] = 69;
    a[32] = 20;
    a[33] = 23;
    a[34] = 51;
    a[35] = 50;
    a[36] = 16;
    a[37] = 55;
    a[38] = 27;
    a[39] = 60;
    a[40] = 88;
    a[41] = 28;
    a[42] = 61;
    a[43] = 95;
    a[44] = 66;
    a[45] = 100;
    a[46] = 103;
    a[47] = 106;
    a[48] = 71;
    a[49] = 22;
    a[50] = 35;
    a[51] = 34;
    a[52] = 76;
    a[53] = 79;
    a[54] = 121;
    a[55] = 37;
    a[56] = 25;
    a[57] = 85;
    a[58] = 83;
    a[59] = 132;
    a[60] = 39;
    a[61] = 42;
    a[62] = 92;
    a[63] = 96;
    a[64] = 143;
    a[65] = 94;
    a[66] = 44;
    a[67] = 99;
    a[68] = 152;
    a[69] = 31;
    a[70] = 157;
    a[71] = 48;
    a[72] = 107;
    a[73] = 112;
    a[74] = 110;
    a[75] = 109;
    a[76] = 52;
    a[77] = 172;
    a[78] = 175;
    a[79] = 53;
    a[80] = 180;
    a[81] = 183;
    a[82] = 122;
    a[83] = 58;
    a[84] = 190;
    a[85] = 57;
    a[86] = 195;
    a[87] = 124;
    a[88] = 40;
    a[89] = 130;
    a[90] = 133;
    a[91] = 136;
    a[92] = 62;
    a[93] = 135;
    a[94] = 65;
    a[95] = 43;
    a[96] = 63;
    a[97] = 141;
    a[98] = 144;
    a[99] = 67;
    a[100] = 45;
    a[101] = 226;
    a[102] = 149;
    a[103] = 46;
    a[104] = 233;
    a[105] = 236;
    a[106] = 47;
    a[107] = 72;
    a[108] = 158;
    a[109] = 75;
    a[110] = 74;
    a[111] = 160;
    a[112] = 73;
    a[113] = 166;
    a[114] = 165;
    a[115] = 169;
    a[116] = 259;
    a[117] = 177;
    a[118] = 264;
    a[119] = 267;
    a[120] = 176;
    a[121] = 54;
    a[122] = 82;
    a[123] = 187;
    a[124] = 87;
    a[125] = 280;
    a[126] = 283;
    a[127] = 185;
    a[128] = 189;
    a[129] = 192;
    a[130] = 89;
    a[131] = 294;
    a[132] = 59;
    a[133] = 90;
    a[134] = 196;
    a[135] = 93;
    a[136] = 91;
    a[137] = 203;
    a[138] = 206;
    a[139] = 311;
    a[140] = 205;
    a[141] = 97;
    a[142] = 318;
    a[143] = 64;
    a[144] = 98;
    a[145] = 216;
    a[146] = 215;
    a[147] = 329;
    a[148] = 218;
    a[149] = 102;
    a[150] = 336;
    a[151] = 223;
    a[152] = 68;
    a[153] = 343;
    a[154] = 346;
    a[155] = 349;
    a[156] = 352;
    a[157] = 70;
    a[158] = 108;
    a[159] = 234;
    a[160] = 111;
    a[161] = 237;
    a[162] = 242;
    a[163] = 240;
    a[164] = 238;
    a[165] = 114;
    a[166] = 113;
    a[167] = 245;
    a[168] = 253;
    a[169] = 115;
    a[170] = 381;
    a[171] = 384;
    a[172] = 77;
    a[173] = 254;
    a[174] = 257;
    a[175] = 78;
    a[176] = 120;
    a[177] = 117;
    a[178] = 260;
    a[179] = 401;
    a[180] = 80;
    a[181] = 269;
    a[182] = 408;
    a[183] = 81;
    a[184] = 270;
    a[185] = 127;
    a[186] = 275;
    a[187] = 123;
    a[188] = 281;
    a[189] = 128;
    a[190] = 84;
    a[191] = 427;
    a[192] = 129;
    a[193] = 284;
    a[194] = 434;
    a[195] = 86;
    a[196] = 134;
    a[197] = 291;
    a[198] = 290;
    a[199] = 289;
    a[200] = 296;
    a[201] = 449;
    a[202] = 303;
    a[203] = 137;
    a[204] = 309;
    a[205] = 140;
    a[206] = 138;
    a[207] = 462;
    a[208] = 465;
    a[209] = 307;
    a[210] = 470;
    a[211] = 310;
    a[212] = 475;
    a[213] = 316;
    a[214] = 480;
    a[215] = 146;
    a[216] = 145;
    a[217] = 487;
    a[218] = 148;
    a[219] = 323;
    a[220] = 494;
    a[221] = 497;
    a[222] = 330;
    a[223] = 151;
    a[224] = 504;
    a[225] = 332;
    a[226] = 101;
    a[227] = 337;
    a[228] = 340;
    a[229] = 515;
    a[230] = 518;
    a[231] = 342;
    a[232] = 345;
    a[233] = 104;
    a[234] = 159;
    a[235] = 529;
    a[236] = 105;
    a[237] = 161;
    a[238] = 164;
    a[239] = 353;
    a[240] = 163;
    a[241] = 356;
    a[242] = 162;
    a[243] = 359;
    a[244] = 364;
    a[245] = 167;
    a[246] = 552;
    a[247] = 366;
    a[248] = 375;
    a[249] = 559;
    a[250] = 368;
    a[251] = 372;
    a[252] = 566;
    a[253] = 168;
    a[254] = 173;
    a[255] = 377;
    a[256] = 373;
    a[257] = 174;
    a[258] = 382;
    a[259] = 116;
    a[260] = 178;
    a[261] = 387;
    a[262] = 587;
    a[263] = 386;
    a[264] = 118;
    a[265] = 393;
    a[266] = 596;
    a[267] = 119;
    a[268] = 398;
    a[269] = 181;
    a[270] = 184;
    a[271] = 607;
    a[272] = 610;
    a[273] = 405;
    a[274] = 615;
    a[275] = 186;
    a[276] = 620;
    a[277] = 623;
    a[278] = 411;
    a[279] = 414;
    a[280] = 125;
    a[281] = 188;
    a[282] = 416;
    a[283] = 126;
    a[284] = 193;
    a[285] = 421;
    a[286] = 642;
    a[287] = 424;
    a[288] = 647;
    a[289] = 199;
    a[290] = 198;
    a[291] = 197;
    a[292] = 430;
    a[293] = 433;
    a[294] = 131;
    a[295] = 662;
    a[296] = 200;
    a[297] = 436;
    a[298] = 439;
    a[299] = 446;
    a[300] = 444;
    a[301] = 443;
    a[302] = 677;
    a[303] = 202;
    a[304] = 682;
    a[305] = 685;
    a[306] = 688;
    a[307] = 209;
    a[308] = 453;
    a[309] = 204;
    a[310] = 211;
    a[311] = 139;
    a[312] = 701;
    a[313] = 704;
    a[314] = 464;
    a[315] = 709;
    a[316] = 213;
    a[317] = 466;
    a[318] = 142;
    a[319] = 472;
    a[320] = 471;
    a[321] = 722;
    a[322] = 474;
    a[323] = 219;
    a[324] = 729;
    a[325] = 483;
    a[326] = 734;
    a[327] = 481;
    a[328] = 484;
    a[329] = 147;
    a[330] = 222;
    a[331] = 745;
    a[332] = 225;
    a[333] = 492;
    a[334] = 752;
    a[335] = 495;
    a[336] = 150;
    a[337] = 227;
    a[338] = 761;
    a[339] = 500;
    a[340] = 228;
    a[341] = 503;
    a[342] = 231;
    a[343] = 153;
    a[344] = 508;
    a[345] = 232;
    a[346] = 154;
    a[347] = 512;
    a[348] = 782;
    a[349] = 155;
    a[350] = 516;
    a[351] = 519;
    a[352] = 156;
    a[353] = 239;
    a[354] = 521;
    a[355] = 524;
    a[356] = 241;
    a[357] = 801;
    a[358] = 804;
    a[359] = 243;
    a[360] = 531;
    a[361] = 811;
    a[362] = 814;
    a[363] = 533;
    a[364] = 244;
    a[365] = 538;
    a[366] = 247;
    a[367] = 825;
    a[368] = 250;
    a[369] = 544;
    a[370] = 549;
    a[371] = 834;
    a[372] = 251;
    a[373] = 256;
    a[374] = 841;
    a[375] = 248;
    a[376] = 550;
    a[377] = 255;
    a[378] = 555;
    a[379] = 560;
    a[380] = 565;
    a[381] = 170;
    a[382] = 258;
    a[383] = 563;
    a[384] = 171;
    a[385] = 573;
    a[386] = 263;
    a[387] = 261;
    a[388] = 572;
    a[389] = 567;
    a[390] = 581;
    a[391] = 876;
    a[392] = 879;
    a[393] = 265;
    a[394] = 884;
    a[395] = 590;
    a[396] = 579;
    a[397] = 584;
    a[398] = 268;
    a[399] = 895;
    a[400] = 593;
    a[401] = 179;
    a[402] = 902;
    a[403] = 592;
    a[404] = 602;
    a[405] = 273;
    a[406] = 911;
    a[407] = 914;
    a[408] = 182;
    a[409] = 606;
    a[410] = 921;
    a[411] = 278;
    a[412] = 926;
    a[413] = 929;
    a[414] = 279;
    a[415] = 934;
    a[416] = 282;
    a[417] = 616;
    a[418] = 619;
    a[419] = 943;
    a[420] = 625;
    a[421] = 285;
    a[422] = 624;
    a[423] = 952;
    a[424] = 287;
    a[425] = 629;
    a[426] = 959;
    a[427] = 191;
    a[428] = 628;
    a[429] = 632;
    a[430] = 292;
    a[431] = 637;
    a[432] = 640;
    a[433] = 293;
    a[434] = 194;
    a[435] = 978;
    a[436] = 297;
    a[437] = 644;
    a[438] = 985;
    a[439] = 298;
    a[440] = 990;
    a[441] = 651;
    a[442] = 657;
    a[443] = 301;
    a[444] = 300;
    a[445] = 661;
    a[446] = 299;
    a[447] = 656;
    a[448] = 1007;
    a[449] = 201;
    a[450] = 667;
    a[451] = 663;
    a[452] = 670;
    a[453] = 308;
    a[454] = 668;
    a[455] = 675;
    a[456] = 1024;
    a[457] = 1027;
    a[458] = 1030;
    a[459] = 1033;
    a[460] = 679;
    a[461] = 1038;
    a[462] = 207;
    a[463] = 684;
    a[464] = 314;
    a[465] = 208;
    a[466] = 317;
    a[467] = 1051;
    a[468] = 691;
    a[469] = 1056;
    a[470] = 210;
    a[471] = 320;
    a[472] = 319;
    a[473] = 697;
    a[474] = 322;
    a[475] = 212;
    a[476] = 705;
    a[477] = 702;
    a[478] = 708;
    a[479] = 712;
    a[480] = 214;
    a[481] = 327;
    a[482] = 1083;
    a[483] = 325;
    a[484] = 328;
    a[485] = 713;
    a[486] = 718;
    a[487] = 217;
    a[488] = 715;
    a[489] = 1098;
    a[490] = 721;
    a[491] = 726;
    a[492] = 333;
    a[493] = 1107;
    a[494] = 220;
    a[495] = 335;
    a[496] = 739;
    a[497] = 221;
    a[498] = 732;
    a[499] = 736;
    a[500] = 339;
    a[501] = 742;
    a[502] = 741;
    a[503] = 341;
    a[504] = 224;
    a[505] = 1132;
    a[506] = 1135;
    a[507] = 749;
    a[508] = 344;
    a[509] = 747;
    a[510] = 1144;
    a[511] = 756;
    a[512] = 347;
    a[513] = 1151;
    a[514] = 1154;
    a[515] = 229;
    a[516] = 350;
    a[517] = 766;
    a[518] = 230;
    a[519] = 351;
    a[520] = 764;
    a[521] = 354;
    a[522] = 769;
    a[523] = 773;
    a[524] = 355;
    a[525] = 771;
    a[526] = 1179;
    a[527] = 1182;
    a[528] = 779;
    a[529] = 235;
    a[530] = 1189;
    a[531] = 360;
    a[532] = 786;
    a[533] = 363;
    a[534] = 1198;
    a[535] = 787;
    a[536] = 1203;
    a[537] = 793;
    a[538] = 365;
    a[539] = 792;
    a[540] = 798;
    a[541] = 1214;
    a[542] = 1217;
    a[543] = 1220;
    a[544] = 369;
    a[545] = 1225;
    a[546] = 1228;
    a[547] = 1231;
    a[548] = 807;
    a[549] = 370;
    a[550] = 376;
    a[551] = 812;
    a[552] = 246;
    a[553] = 815;
    a[554] = 1246;
    a[555] = 378;
    a[556] = 820;
    a[557] = 1253;
    a[558] = 823;
    a[559] = 249;
    a[560] = 379;
    a[561] = 1262;
    a[562] = 830;
    a[563] = 383;
    a[564] = 1269;
    a[565] = 380;
    a[566] = 252;
    a[567] = 389;
    a[568] = 835;
    a[569] = 838;
    a[570] = 842;
    a[571] = 1284;
    a[572] = 388;
    a[573] = 385;
    a[574] = 845;
    a[575] = 848;
    a[576] = 853;
    a[577] = 1297;
    a[578] = 859;
    a[579] = 396;
    a[580] = 1304;
    a[581] = 390;
    a[582] = 857;
    a[583] = 861;
    a[584] = 397;
    a[585] = 864;
    a[586] = 1317;
    a[587] = 262;
    a[588] = 1322;
    a[589] = 1325;
    a[590] = 395;
    a[591] = 874;
    a[592] = 403;
    a[593] = 400;
    a[594] = 878;
    a[595] = 1338;
    a[596] = 266;
    a[597] = 1343;
    a[598] = 885;
    a[599] = 1348;
    a[600] = 882;
    a[601] = 886;
    a[602] = 404;
    a[603] = 892;
    a[604] = 1359;
    a[605] = 1362;
    a[606] = 409;
    a[607] = 271;
    a[608] = 901;
    a[609] = 899;
    a[610] = 272;
    a[611] = 1375;
    a[612] = 904;
    a[613] = 1380;
    a[614] = 1383;
    a[615] = 274;
    a[616] = 417;
    a[617] = 908;
    a[618] = 915;
    a[619] = 418;
    a[620] = 276;
    a[621] = 917;
    a[622] = 920;
    a[623] = 277;
    a[624] = 422;
    a[625] = 420;
    a[626] = 925;
    a[627] = 922;
    a[628] = 428;
    a[629] = 425;
    a[630] = 930;
    a[631] = 933;
    a[632] = 429;
    a[633] = 938;
    a[634] = 935;
    a[635] = 1426;
    a[636] = 1429;
    a[637] = 431;
    a[638] = 942;
    a[639] = 947;
    a[640] = 432;
    a[641] = 1440;
    a[642] = 286;
    a[643] = 950;
    a[644] = 437;
    a[645] = 1449;
    a[646] = 949;
    a[647] = 288;
    a[648] = 1456;
    a[649] = 961;
    a[650] = 1461;
    a[651] = 441;
    a[652] = 963;
    a[653] = 962;
    a[654] = 969;
    a[655] = 1472;
    a[656] = 447;
    a[657] = 442;
    a[658] = 1479;
    a[659] = 972;
    a[660] = 1484;
    a[661] = 445;
    a[662] = 295;
    a[663] = 451;
    a[664] = 980;
    a[665] = 983;
    a[666] = 1497;
    a[667] = 450;
    a[668] = 454;
    a[669] = 986;
    a[670] = 452;
    a[671] = 992;
    a[672] = 991;
    a[673] = 997;
    a[674] = 994;
    a[675] = 455;
    a[676] = 1518;
    a[677] = 302;
    a[678] = 1001;
    a[679] = 460;
    a[680] = 1015;
    a[681] = 1003;
    a[682] = 304;
    a[683] = 1533;
    a[684] = 463;
    a[685] = 305;
    a[686] = 1012;
    a[687] = 1016;
    a[688] = 306;
    a[689] = 1546;
    a[690] = 1017;
    a[691] = 468;
    a[692] = 1023;
    a[693] = 1021;
    a[694] = 1557;
    a[695] = 1560;
    a[696] = 1563;
    a[697] = 473;
    a[698] = 1568;
    a[699] = 1032;
    a[700] = 1573;
    a[701] = 312;
    a[702] = 477;
    a[703] = 1035;
    a[704] = 313;
    a[705] = 476;
    a[706] = 1043;
    a[707] = 1041;
    a[708] = 478;
    a[709] = 315;
    a[710] = 1050;
    a[711] = 1054;
    a[712] = 479;
    a[713] = 485;
    a[714] = 1602;
    a[715] = 488;
    a[716] = 1055;
    a[717] = 1062;
    a[718] = 486;
    a[719] = 1613;
    a[720] = 1616;
    a[721] = 490;
    a[722] = 321;
    a[723] = 1070;
    a[724] = 1625;
    a[725] = 1067;
    a[726] = 491;
    a[727] = 1076;
    a[728] = 1634;
    a[729] = 324;
    a[730] = 1080;
    a[731] = 1641;
    a[732] = 498;
    a[733] = 1085;
    a[734] = 326;
    a[735] = 1650;
    a[736] = 499;
    a[737] = 1088;
    a[738] = 1086;
    a[739] = 496;
    a[740] = 1093;
    a[741] = 502;
    a[742] = 501;
    a[743] = 1097;
    a[744] = 1104;
    a[745] = 331;
    a[746] = 1101;
    a[747] = 509;
    a[748] = 1677;
    a[749] = 507;
    a[750] = 1112;
    a[751] = 1108;
    a[752] = 334;
    a[753] = 1111;
    a[754] = 1115;
    a[755] = 1692;
    a[756] = 511;
    a[757] = 1697;
    a[758] = 1700;
    a[759] = 1122;
    a[760] = 1705;
    a[761] = 338;
    a[762] = 1126;
    a[763] = 1129;
    a[764] = 520;
    a[765] = 1716;
    a[766] = 517;
    a[767] = 1721;
    a[768] = 1133;
    a[769] = 522;
    a[770] = 1139;
    a[771] = 525;
    a[772] = 1145;
    a[773] = 523;
    a[774] = 1142;
    a[775] = 1738;
    a[776] = 1152;
    a[777] = 1147;
    a[778] = 1745;
    a[779] = 528;
    a[780] = 1750;
    a[781] = 1753;
    a[782] = 348;
    a[783] = 1155;
    a[784] = 1760;
    a[785] = 1162;
    a[786] = 532;
    a[787] = 535;
    a[788] = 1159;
    a[789] = 1771;
    a[790] = 1164;
    a[791] = 1170;
    a[792] = 539;
    a[793] = 537;
    a[794] = 1175;
    a[795] = 1784;
    a[796] = 1787;
    a[797] = 1790;
    a[798] = 540;
    a[799] = 1795;
    a[800] = 1798;
    a[801] = 357;
    a[802] = 1186;
    a[803] = 1805;
    a[804] = 358;
    a[805] = 1188;
    a[806] = 1191;
    a[807] = 548;
    a[808] = 1196;
    a[809] = 1195;
    a[810] = 1820;
    a[811] = 361;
    a[812] = 551;
    a[813] = 1200;
    a[814] = 362;
    a[815] = 553;
    a[816] = 1208;
    a[817] = 1835;
    a[818] = 1211;
    a[819] = 1209;
    a[820] = 556;
    a[821] = 1844;
    a[822] = 1847;
    a[823] = 558;
    a[824] = 1852;
    a[825] = 367;
    a[826] = 1221;
    a[827] = 1224;
    a[828] = 1861;
    a[829] = 1864;
    a[830] = 562;
    a[831] = 1229;
    a[832] = 1232;
    a[833] = 1873;
    a[834] = 371;
    a[835] = 568;
    a[836] = 1235;
    a[837] = 1233;
    a[838] = 569;
    a[839] = 1242;
    a[840] = 1252;
    a[841] = 374;
    a[842] = 570;
    a[843] = 1894;
    a[844] = 1897;
    a[845] = 574;
    a[846] = 1248;
    a[847] = 1251;
    a[848] = 575;
    a[849] = 1256;
    a[850] = 1266;
    a[851] = 1912;
    a[852] = 1915;
    a[853] = 576;
    a[854] = 1260;
    a[855] = 1264;
    a[856] = 1267;
    a[857] = 582;
    a[858] = 1928;
    a[859] = 578;
    a[860] = 1270;
    a[861] = 583;
    a[862] = 1275;
    a[863] = 1939;
    a[864] = 585;
    a[865] = 1944;
    a[866] = 1281;
    a[867] = 1949;
    a[868] = 1952;
    a[869] = 1955;
    a[870] = 1958;
    a[871] = 1288;
    a[872] = 1963;
    a[873] = 1966;
    a[874] = 591;
    a[875] = 1294;
    a[876] = 391;
    a[877] = 1975;
    a[878] = 594;
    a[879] = 392;
    a[880] = 1300;
    a[881] = 1303;
    a[882] = 600;
    a[883] = 1311;
    a[884] = 394;
    a[885] = 598;
    a[886] = 601;
    a[887] = 1308;
    a[888] = 1312;
    a[889] = 1315;
    a[890] = 1319;
    a[892] = 603;
    a[893] = 1318;
    a[894] = 1326;
    a[895] = 399;
    a[896] = 1323;
    a[899] = 609;
    a[900] = 1330;
    a[901] = 608;
    a[902] = 402;
    a[903] = 1334;
    a[904] = 612;
    a[905] = 1345;
    a[906] = 1339;
    a[908] = 617;
    a[909] = 1344;
    a[911] = 406;
    a[913] = 1350;
    a[914] = 407;
    a[915] = 618;
    a[916] = 1352;
    a[917] = 621;
    a[918] = 1357;
    a[919] = 1360;
    a[920] = 622;
    a[921] = 410;
    a[922] = 627;
    a[923] = 1365;
    a[924] = 1371;
    a[925] = 626;
    a[926] = 412;
    a[927] = 1372;
    a[929] = 413;
    a[930] = 630;
    a[933] = 631;
    a[934] = 415;
    a[935] = 634;
    a[936] = 1374;
    a[937] = 1385;
    a[938] = 633;
    a[939] = 1382;
    a[940] = 1389;
    a[941] = 1394;
    a[942] = 638;
    a[943] = 419;
    a[944] = 1401;
    a[946] = 1400;
    a[947] = 639;
    a[948] = 1399;
    a[949] = 646;
    a[950] = 643;
    a[951] = 1407;
    a[952] = 423;
    a[955] = 1410;
    a[959] = 426;
    a[960] = 1419;
    a[961] = 649;
    a[962] = 653;
    a[963] = 652;
    a[964] = 1424;
    a[965] = 1427;
    a[969] = 654;
    a[970] = 1435;
    a[971] = 1432;
    a[972] = 659;
    a[975] = 1443;
    a[978] = 435;
    a[979] = 1450;
    a[980] = 664;
    a[981] = 1445;
    a[982] = 1448;
    a[983] = 665;
    a[984] = 1453;
    a[985] = 438;
    a[986] = 669;
    a[987] = 1460;
    a[988] = 1458;
    a[989] = 1466;
    a[990] = 440;
    a[991] = 672;
    a[992] = 671;
    a[993] = 1467;
    a[994] = 674;
    a[995] = 1470;
    a[996] = 1468;
    a[997] = 673;
    a[999] = 1475;
    a[1001] = 678;
    a[1003] = 681;
    a[1004] = 1482;
    a[1005] = 1485;
    a[1007] = 448;
    a[1008] = 1487;
    a[1009] = 1491;
    a[1012] = 686;
    a[1013] = 1494;
    a[1014] = 1498;
    a[1015] = 680;
    a[1016] = 687;
    a[1017] = 690;
    a[1018] = 1501;
    a[1019] = 1507;
    a[1020] = 1506;
    a[1021] = 693;
    a[1023] = 692;
    a[1024] = 456;
    a[1025] = 1514;
    a[1027] = 457;
    a[1030] = 458;
    a[1031] = 1522;
    a[1032] = 699;
    a[1033] = 459;
    a[1034] = 1526;
    a[1035] = 703;
    a[1036] = 1531;
    a[1037] = 1535;
    a[1038] = 461;
    a[1039] = 1532;
    a[1041] = 707;
    a[1042] = 1539;
    a[1043] = 706;
    a[1046] = 1540;
    a[1048] = 1549;
    a[1050] = 710;
    a[1051] = 467;
    a[1053] = 1552;
    a[1054] = 711;
    a[1055] = 716;
    a[1056] = 469;
    a[1057] = 1561;
    a[1059] = 1567;
    a[1060] = 1562;
    a[1062] = 717;
    a[1063] = 1566;
    a[1065] = 1571;
    a[1066] = 1576;
    a[1067] = 725;
    a[1068] = 1581;
    a[1070] = 723;
    a[1073] = 1582;
    a[1074] = 1586;
    a[1076] = 727;
    a[1078] = 1593;
    a[1080] = 730;
    a[1082] = 1599;
    a[1083] = 482;
    a[1085] = 733;
    a[1086] = 738;
    a[1087] = 1605;
    a[1088] = 737;
    a[1089] = 1611;
    a[1090] = 1610;
    a[1092] = 1618;
    a[1093] = 740;
    a[1094] = 1617;
    a[1097] = 743;
    a[1098] = 489;
    a[1099] = 1620;
    a[1100] = 1628;
    a[1101] = 746;
    a[1103] = 1630;
    a[1104] = 744;
    a[1105] = 1636;
    a[1107] = 493;
    a[1108] = 751;
    a[1109] = 1639;
    a[1111] = 753;
    a[1112] = 750;
    a[1113] = 1645;
    a[1114] = 1651;
    a[1115] = 754;
    a[1117] = 1652;
    a[1119] = 1655;
    a[1121] = 1646;
    a[1122] = 759;
    a[1123] = 1662;
    a[1124] = 1658;
    a[1126] = 762;
    a[1127] = 1665;
    a[1128] = 1669;
    a[1129] = 763;
    a[1130] = 1674;
    a[1131] = 1671;
    a[1132] = 505;
    a[1133] = 768;
    a[1135] = 506;
    a[1136] = 1678;
    a[1139] = 770;
    a[1140] = 1685;
    a[1142] = 774;
    a[1144] = 510;
    a[1145] = 772;
    a[1147] = 777;
    a[1148] = 1694;
    a[1149] = 1698;
    a[1150] = 1701;
    a[1151] = 513;
    a[1152] = 776;
    a[1154] = 514;
    a[1155] = 783;
    a[1156] = 1708;
    a[1157] = 1711;
    a[1158] = 1706;
    a[1159] = 788;
    a[1160] = 1713;
    a[1161] = 1717;
    a[1162] = 785;
    a[1163] = 1720;
    a[1164] = 790;
    a[1165] = 1729;
    a[1166] = 1724;
    a[1168] = 1723;
    a[1170] = 791;
    a[1171] = 1731;
    a[1172] = 1735;
    a[1173] = 1734;
    a[1175] = 794;
    a[1178] = 1740;
    a[1179] = 526;
    a[1182] = 527;
    a[1183] = 1748;
    a[1184] = 1751;
    a[1186] = 802;
    a[1188] = 805;
    a[1189] = 530;
    a[1190] = 1756;
    a[1191] = 806;
    a[1192] = 1763;
    a[1193] = 1766;
    a[1194] = 1769;
    a[1195] = 809;
    a[1196] = 808;
    a[1198] = 534;
    a[1199] = 1768;
    a[1200] = 813;
    a[1203] = 536;
    a[1204] = 1780;
    a[1205] = 1783;
    a[1208] = 816;
    a[1209] = 819;
    a[1210] = 1789;
    a[1211] = 818;
    a[1212] = 1792;
    a[1214] = 541;
    a[1215] = 1797;
    a[1217] = 542;
    a[1218] = 1799;
    a[1219] = 1802;
    a[1220] = 543;
    a[1221] = 826;
    a[1222] = 1815;
    a[1223] = 1808;
    a[1224] = 827;
    a[1225] = 545;
    a[1228] = 546;
    a[1229] = 831;
    a[1230] = 1816;
    a[1231] = 547;
    a[1232] = 832;
    a[1233] = 837;
    a[1234] = 1822;
    a[1235] = 836;
    a[1236] = 1825;
    a[1237] = 1829;
    a[1238] = 1828;
    a[1239] = 1836;
    a[1240] = 1831;
    a[1241] = 1839;
    a[1242] = 839;
    a[1244] = 1838;
    a[1245] = 1851;
    a[1246] = 554;
    a[1248] = 846;
    a[1249] = 1845;
    a[1251] = 847;
    a[1252] = 840;
    a[1253] = 557;
    a[1254] = 1849;
    a[1255] = 1854;
    a[1256] = 849;
    a[1257] = 1860;
    a[1258] = 1858;
    a[1259] = 1866;
    a[1260] = 854;
    a[1261] = 1865;
    a[1262] = 561;
    a[1264] = 855;
    a[1265] = 1870;
    a[1266] = 850;
    a[1267] = 856;
    a[1269] = 564;
    a[1270] = 860;
    a[1272] = 1874;
    a[1273] = 1884;
    a[1275] = 862;
    a[1276] = 1886;
    a[1277] = 1885;
    a[1279] = 1891;
    a[1281] = 866;
    a[1282] = 1900;
    a[1283] = 1898;
    a[1284] = 571;
    a[1287] = 1903;
    a[1288] = 871;
    a[1289] = 1902;
    a[1290] = 1907;
    a[1294] = 875;
    a[1296] = 1917;
    a[1297] = 577;
    a[1299] = 1918;
    a[1300] = 880;
    a[1301] = 1921;
    a[1302] = 1925;
    a[1303] = 881;
    a[1304] = 580;
    a[1305] = 1927;
    a[1306] = 1934;
    a[1308] = 887;
    a[1309] = 1933;
    a[1311] = 883;
    a[1312] = 888;
    a[1315] = 889;
    a[1316] = 1941;
    a[1317] = 586;
    a[1318] = 893;
    a[1319] = 890;
    a[1320] = 1946;
    a[1321] = 1953;
    a[1322] = 588;
    a[1323] = 896;
    a[1325] = 589;
    a[1326] = 894;
    a[1327] = 1962;
    a[1328] = 1961;
    a[1329] = 1959;
    a[1330] = 900;
    a[1331] = 1972;
    a[1332] = 1968;
    a[1333] = 1980;
    a[1334] = 903;
    a[1336] = 1967;
    a[1337] = 1974;
    a[1338] = 595;
    a[1339] = 906;
    a[1340] = 1979;
    a[1341] = 1998;
    a[1342] = 1986;
    a[1343] = 597;
    a[1344] = 909;
    a[1345] = 905;
    a[1347] = 1990;
    a[1348] = 599;
    a[1350] = 913;
    a[1351] = 1993;
    a[1352] = 916;
    a[1353] = 1999;
    a[1357] = 918;
    a[1359] = 604;
    a[1360] = 919;
    a[1362] = 605;
    a[1365] = 923;
    a[1371] = 924;
    a[1372] = 927;
    a[1374] = 936;
    a[1375] = 611;
    a[1380] = 613;
    a[1382] = 939;
    a[1383] = 614;
    a[1385] = 937;
    a[1389] = 940;
    a[1394] = 941;
    a[1399] = 948;
    a[1400] = 946;
    a[1401] = 944;
    a[1407] = 951;
    a[1410] = 955;
    a[1419] = 960;
    a[1424] = 964;
    a[1426] = 635;
    a[1427] = 965;
    a[1429] = 636;
    a[1432] = 971;
    a[1435] = 970;
    a[1440] = 641;
    a[1443] = 975;
    a[1445] = 981;
    a[1448] = 982;
    a[1449] = 645;
    a[1450] = 979;
    a[1453] = 984;
    a[1456] = 648;
    a[1458] = 988;
    a[1460] = 987;
    a[1461] = 650;
    a[1466] = 989;
    a[1467] = 993;
    a[1468] = 996;
    a[1470] = 995;
    a[1472] = 655;
    a[1475] = 999;
    a[1479] = 658;
    a[1482] = 1004;
    a[1484] = 660;
    a[1485] = 1005;
    a[1487] = 1008;
    a[1491] = 1009;
    a[1494] = 1013;
    a[1497] = 666;
    a[1498] = 1014;
    a[1501] = 1018;
    a[1506] = 1020;
    a[1507] = 1019;
    a[1514] = 1025;
    a[1518] = 676;
    a[1522] = 1031;
    a[1526] = 1034;
    a[1531] = 1036;
    a[1532] = 1039;
    a[1533] = 683;
    a[1535] = 1037;
    a[1539] = 1042;
    a[1540] = 1046;
    a[1546] = 689;
    a[1549] = 1048;
    a[1552] = 1053;
    a[1557] = 694;
    a[1560] = 695;
    a[1561] = 1057;
    a[1562] = 1060;
    a[1563] = 696;
    a[1566] = 1063;
    a[1567] = 1059;
    a[1568] = 698;
    a[1571] = 1065;
    a[1573] = 700;
    a[1576] = 1066;
    a[1581] = 1068;
    a[1582] = 1073;
    a[1586] = 1074;
    a[1593] = 1078;
    a[1599] = 1082;
    a[1602] = 714;
    a[1605] = 1087;
    a[1610] = 1090;
    a[1611] = 1089;
    a[1613] = 719;
    a[1616] = 720;
    a[1617] = 1094;
    a[1618] = 1092;
    a[1620] = 1099;
    a[1625] = 724;
    a[1628] = 1100;
    a[1630] = 1103;
    a[1634] = 728;
    a[1636] = 1105;
    a[1639] = 1109;
    a[1641] = 731;
    a[1645] = 1113;
    a[1646] = 1121;
    a[1650] = 735;
    a[1651] = 1114;
    a[1652] = 1117;
    a[1655] = 1119;
    a[1658] = 1124;
    a[1662] = 1123;
    a[1665] = 1127;
    a[1669] = 1128;
    a[1671] = 1131;
    a[1674] = 1130;
    a[1677] = 748;
    a[1678] = 1136;
    a[1685] = 1140;
    a[1692] = 755;
    a[1694] = 1148;
    a[1697] = 757;
    a[1698] = 1149;
    a[1700] = 758;
    a[1701] = 1150;
    a[1705] = 760;
    a[1706] = 1158;
    a[1708] = 1156;
    a[1711] = 1157;
    a[1713] = 1160;
    a[1716] = 765;
    a[1717] = 1161;
    a[1720] = 1163;
    a[1721] = 767;
    a[1723] = 1168;
    a[1724] = 1166;
    a[1729] = 1165;
    a[1731] = 1171;
    a[1734] = 1173;
    a[1735] = 1172;
    a[1738] = 775;
    a[1740] = 1178;
    a[1745] = 778;
    a[1748] = 1183;
    a[1750] = 780;
    a[1751] = 1184;
    a[1753] = 781;
    a[1756] = 1190;
    a[1760] = 784;
    a[1763] = 1192;
    a[1766] = 1193;
    a[1768] = 1199;
    a[1769] = 1194;
    a[1771] = 789;
    a[1780] = 1204;
    a[1783] = 1205;
    a[1784] = 795;
    a[1787] = 796;
    a[1789] = 1210;
    a[1790] = 797;
    a[1792] = 1212;
    a[1795] = 799;
    a[1797] = 1215;
    a[1798] = 800;
    a[1799] = 1218;
    a[1802] = 1219;
    a[1805] = 803;
    a[1808] = 1223;
    a[1815] = 1222;
    a[1816] = 1230;
    a[1820] = 810;
    a[1822] = 1234;
    a[1825] = 1236;
    a[1828] = 1238;
    a[1829] = 1237;
    a[1831] = 1240;
    a[1835] = 817;
    a[1836] = 1239;
    a[1838] = 1244;
    a[1839] = 1241;
    a[1844] = 821;
    a[1845] = 1249;
    a[1847] = 822;
    a[1849] = 1254;
    a[1851] = 1245;
    a[1852] = 824;
    a[1854] = 1255;
    a[1858] = 1258;
    a[1860] = 1257;
    a[1861] = 828;
    a[1864] = 829;
    a[1865] = 1261;
    a[1866] = 1259;
    a[1870] = 1265;
    a[1873] = 833;
    a[1874] = 1272;
    a[1884] = 1273;
    a[1885] = 1277;
    a[1886] = 1276;
    a[1891] = 1279;
    a[1894] = 843;
    a[1897] = 844;
    a[1898] = 1283;
    a[1900] = 1282;
    a[1902] = 1289;
    a[1903] = 1287;
    a[1907] = 1290;
    a[1912] = 851;
    a[1915] = 852;
    a[1917] = 1296;
    a[1918] = 1299;
    a[1921] = 1301;
    a[1925] = 1302;
    a[1927] = 1305;
    a[1928] = 858;
    a[1933] = 1309;
    a[1934] = 1306;
    a[1939] = 863;
    a[1941] = 1316;
    a[1944] = 865;
    a[1946] = 1320;
    a[1949] = 867;
    a[1952] = 868;
    a[1953] = 1321;
    a[1955] = 869;
    a[1958] = 870;
    a[1959] = 1329;
    a[1961] = 1328;
    a[1962] = 1327;
    a[1963] = 872;
    a[1966] = 873;
    a[1967] = 1336;
    a[1968] = 1332;
    a[1972] = 1331;
    a[1974] = 1337;
    a[1975] = 877;
    a[1979] = 1340;
    a[1980] = 1333;
    a[1986] = 1342;
    a[1990] = 1347;
    a[1993] = 1351;
    a[1998] = 1341;
    a[1999] = 1353;
    cin >> T;
    while(T--) {
        solve();
    }
    return 0;
}

详细

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3464kb

input:

3
5
2 3
3 2
3 3
3 3
3 3
1
2 4
2
1 1
3 2

output:

1 1 1
-1 -1 -1
2 1 1

result:

wrong answer 1st lines differ - expected: '3 1 1', found: '1 1 1'