Submission #737047

# Submission time Handle Problem Language Result Execution time Memory
737047 2023-05-06T13:52:40 Z mjhmjh1104 Present (RMI21_present) C++17
0 / 100
4000 ms 9956 KB
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

int gcd(int x, int y) {
    if (!x || !y) return x + y;
    return x % y ? gcd(y, x % y) : y;
}

int g[26][26];

bool validate(const int &v) {
    for (int i = 0; i < 25; i++) if (v & 1 << i) for (int j = i + 1; j < 25; j++) if (v & 1 << j) {
        int k = g[i + 1][j + 1] - 1;
        if (~v & 1 << k) return false;
    }
    return true;
}

int t, k;
vector<int> lt;

int main() {
    for (int i = 0; i < 26; i++) for (int j = 0; j < 26; j++) g[i][j] = gcd(i, j);
    lt = { 0,2,4,8,10,16,32,34,36,42,64,128,130,136,138,162,170,256,260,292,512,514,522,528,546,554,642,650,674,682,1024,2048,2050,2052,2056,2058,2080,2082,2084,2090,2184,2186,2218,2308,2340,2562,2570,2594,2602,2698,2730,4096,8192,8194,8202,8226,8234,8256,8322,8330,8354,8362,8706,8714,8738,8746,8834,8842,8866,8874,10242,10250,10274,10282,10378,10410,10754,10762,10786,10794,10890,10922,16384,16388,16400,16420,16644,16676,16912,18436,18468,18692,18724,32768,32770,32776,32778,32802,32810,32896,32898,32904,32906,32930,32938,33282,33290,33314,33322,33410,33418,33442,33450,34824,34826,34858,34952,34954,34986,35338,35370,35466,35498,40962,40970,40994,41002,41090,41098,41122,41130,41474,41482,41506,41514,41602,41610,41634,41642,43018,43050,43146,43178,43530,43562,43658,43690,65536,131072,131074,131076,131082,131104,131106,131108,131114,131202,131210,131234,131242,131328,131332,131364,131586,131594,131618,131626,131714,131722,131746,131754,133152,133154,133156,133162,133290,133412,133666,133674,133802,139266,139274,139298,139306,139394,139402,139426,139434,139778,139786,139810,139818,139906,139914,139938,139946,141346,141354,141482,141858,141866,141994,147460,147492,147716,147748,149540,149796,163842,163850,163874,163882,163970,163978,164002,164010,164354,164362,164386,164394,164482,164490,164514,164522,165930,166058,166442,166570,172034,172042,172066,172074,172162,172170,172194,172202,172546,172554,172578,172586,172674,172682,172706,172714,174122,174250,174634,174762,262144,524288,524290,524296,524298,524304,524322,524330,524424,524426,524458,524800,524802,524810,524816,524834,524842,524938,524970,526344,526346,526378,526472,526474,526506,526858,526890,526986,527018,532482,532490,532514,532522,532618,532650,532994,533002,533026,533034,533130,533162,534538,534570,534666,534698,535050,535082,535178,535210,540688,541200,557064,557066,557098,557192,557194,557226,557578,557610,557706,557738,559112,559114,559146,559240,559242,559274,559626,559658,559754,559786,565258,565290,565386,565418,565770,565802,565898,565930,567306,567338,567434,567466,567818,567850,567946,567978,655362,655370,655394,655402,655498,655530,655874,655882,655906,655914,656010,656042,657450,657578,657962,658090,663554,663562,663586,663594,663690,663722,664066,664074,664098,664106,664202,664234,665642,665770,666154,666282,688138,688170,688266,688298,688650,688682,688778,688810,690218,690346,690730,690858,696330,696362,696458,696490,696842,696874,696970,697002,698410,698538,698922,699050,1048576,1048580,1048612,1048640,1048836,1048868,1050628,1050660,1050884,1050916,1056832,1064964,1064996,1065220,1065252,1067012,1067044,1067268,1067300,1179652,1179684,1179908,1179940,1181732,1181988,1196036,1196068,1196292,1196324,1198116,1198372,2097152,2097154,2097162,2097186,2097194,2097282,2097290,2097314,2097322,2097666,2097674,2097698,2097706,2097794,2097802,2097826,2097834,2098176,2099202,2099210,2099234,2099242,2099338,2099370,2099714,2099722,2099746,2099754,2099850,2099882,2105346,2105354,2105378,2105386,2105474,2105482,2105506,2105514,2105858,2105866,2105890,2105898,2105986,2105994,2106018,2106026,2107394,2107402,2107426,2107434,2107530,2107562,2107906,2107914,2107938,2107946,2108042,2108074,2129922,2129930,2129954,2129962,2130050,2130058,2130082,2130090,2130434,2130442,2130466,2130474,2130562,2130570,2130594,2130602,2131978,2132010,2132106,2132138,2132490,2132522,2132618,2132650,2138114,2138122,2138146,2138154,2138242,2138250,2138274,2138282,2138626,2138634,2138658,2138666,2138754,2138762,2138786,2138794,2140170,2140202,2140298,2140330,2140682,2140714,2140810,2140842,2228226,2228234,2228258,2228266,2228354,2228362,2228386,2228394,2228738,2228746,2228770,2228778,2228866,2228874,2228898,2228906,2230306,2230314,2230442,2230818,2230826,2230954,2236418,2236426,2236450,2236458,2236546,2236554,2236578,2236586,2236930,2236938,2236962,2236970,2237058,2237066,2237090,2237098,2238498,2238506,2238634,2239010,2239018,2239146,2260994,2261002,2261026,2261034,2261122,2261130,2261154,2261162,2261506,2261514,2261538,2261546,2261634,2261642,2261666,2261674,2263082,2263210,2263594,2263722,2269186,2269194,2269218,2269226,2269314,2269322,2269346,2269354,2269698,2269706,2269730,2269738,2269826,2269834,2269858,2269866,2271274,2271402,2271786,2271914,2621442,2621450,2621474,2621482,2621578,2621610,2621954,2621962,2621986,2621994,2622090,2622122,2623498,2623530,2623626,2623658,2624010,2624042,2624138,2624170,2629634,2629642,2629666,2629674,2629770,2629802,2630146,2630154,2630178,2630186,2630282,2630314,2631690,2631722,2631818,2631850,2632202,2632234,2632330,2632362,2654218,2654250,2654346,2654378,2654730,2654762,2654858,2654890,2656266,2656298,2656394,2656426,2656778,2656810,2656906,2656938,2662410,2662442,2662538,2662570,2662922,2662954,2663050,2663082,2664458,2664490,2664586,2664618,2664970,2665002,2665098,2665130,2752514,2752522,2752546,2752554,2752650,2752682,2753026,2753034,2753058,2753066,2753162,2753194,2754602,2754730,2755114,2755242,2760706,2760714,2760738,2760746,2760842,2760874,2761218,2761226,2761250,2761258,2761354,2761386,2762794,2762922,2763306,2763434,2785290,2785322,2785418,2785450,2785802,2785834,2785930,2785962,2787370,2787498,2787882,2788010,2793482,2793514,2793610,2793642,2793994,2794026,2794122,2794154,2795562,2795690,2796074,2796202,4194304,8388608,8388610,8388612,8388616,8388618,8388640,8388642,8388644,8388650,8388736,8388738,8388744,8388746,8388770,8388778,8388868,8388900,8389122,8389130,8389154,8389162,8389250,8389258,8389282,8389290,8390656,8390658,8390660,8390664,8390666,8390688,8390690,8390692,8390698,8390792,8390794,8390826,8390916,8390948,8391170,8391178,8391202,8391210,8391306,8391338,8396802,8396810,8396834,8396842,8396930,8396938,8396962,8396970,8397314,8397322,8397346,8397354,8397442,8397450,8397474,8397482,8398850,8398858,8398882,8398890,8398986,8399018,8399362,8399370,8399394,8399402,8399498,8399530,8404996,8405028,8405252,8405284,8407044,8407076,8407300,8407332,8421504,8421506,8421512,8421514,8421538,8421546,8422018,8422026,8422050,8422058,8423560,8423562,8423594,8424074,8424106,8429698,8429706,8429730,8429738,8430210,8430218,8430242,8430250,8431754,8431786,8432266,8432298,8519712,8519714,8519716,8519722,8519842,8519850,8519972,8520226,8520234,8520354,8520362,8521760,8521762,8521764,8521770,8521898,8522020,8522274,8522282,8522410,8527906,8527914,8528034,8528042,8528418,8528426,8528546,8528554,8529954,8529962,8530090,8530466,8530474,8530602,8536100,8536356,8538148,8538404,8552610,8552618,8553122,8553130,8554666,8555178,8560802,8560810,8561314,8561322,8562858,8563370,8912904,8912906,8912938,8913032,8913034,8913066,8913418,8913450,8913546,8913578,8914952,8914954,8914986,8915080,8915082,8915114,8915466,8915498,8915594,8915626,8921098,8921130,8921226,8921258,8921610,8921642,8921738,8921770,8923146,8923178,8923274,8923306,8923658,8923690,8923786,8923818,8945800,8945802,8945834,8946314,8946346,8947848,8947850,8947882,8948362,8948394,8953994,8954026,8954506,8954538,8956042,8956074,8956554,8956586,9044010,9044138,9044522,9044650,9046058,9046186,9046570,9046698,9052202,9052330,9052714,9052842,9054250,9054378,9054762,9054890,9076906,9077418,9078954,9079466,9085098,9085610,9087146,9087658,9437188,9437220,9437444,9437476,9439236,9439268,9439492,9439524,9453572,9453604,9453828,9453860,9455620,9455652,9455876,9455908,9568292,9568548,9570340,9570596,9584676,9584932,9586724,9586980,10485762,10485770,10485794,10485802,10485890,10485898,10485922,10485930,10486274,10486282,10486306,10486314,10486402,10486410,10486434,10486442,10487810,10487818,10487842,10487850,10487946,10487978,10488322,10488330,10488354,10488362,10488458,10488490,10493954,10493962,10493986,10493994,10494082,10494090,10494114,10494122,10494466,10494474,10494498,10494506,10494594,10494602,10494626,10494634,10496002,10496010,10496034,10496042,10496138,10496170,10496514,10496522,10496546,10496554,10496650,10496682,10518658,10518666,10518690,10518698,10519170,10519178,10519202,10519210,10520714,10520746,10521226,10521258,10526850,10526858,10526882,10526890,10527362,10527370,10527394,10527402,10528906,10528938,10529418,10529450,10616866,10616874,10616994,10617002,10617378,10617386,10617506,10617514,10618914,10618922,10619050,10619426,10619434,10619562,10625058,10625066,10625186,10625194,10625570,10625578,10625698,10625706,10627106,10627114,10627242,10627618,10627626,10627754,10649762,10649770,10650274,10650282,10651818,10652330,10657954,10657962,10658466,10658474,10660010,10660522,11010058,11010090,11010186,11010218,11010570,11010602,11010698,11010730,11012106,11012138,11012234,11012266,11012618,11012650,11012746,11012778,11018250,11018282,11018378,11018410,11018762,11018794,11018890,11018922,11020298,11020330,11020426,11020458,11020810,11020842,11020938,11020970,11042954,11042986,11043466,11043498,11045002,11045034,11045514,11045546,11051146,11051178,11051658,11051690,11053194,11053226,11053706,11053738,11141162,11141290,11141674,11141802,11143210,11143338,11143722,11143850,11149354,11149482,11149866,11149994,11151402,11151530,11151914,11152042,11174058,11174570,11176106,11176618,11182250,11182762,11184298,11184810,16777216,16777232,16777744,16793616,16794128,17301520,17302032,17317904,17318416 };
    for (int i = 0; i < 1 << 24; i++) {
        if (!validate(i * 2 + 1)) continue;
        lt.push_back(i * 2 + 1);
    }
    sort(lt.begin(), lt.end(), [](const int &x, const int &y) {
        for (int i = 24; i >= 0; i--) if ((x & 1 << i) != (y & 1 << i)) return (x & 1 << i) < (y & 1 << i);
        return false;
    });
    for (scanf("%d", &t); t--; ) {
        scanf("%d", &k);
        int &c = lt[k];
        vector<int> v;
        for (int i = 0; i < 25; i++) if (c & 1 << i) v.push_back(i + 1);
        printf("%d ", (int)v.size());
        for (auto &i: v) printf("%d ", i);
        puts("");
    }
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:35:15: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   35 |     for (scanf("%d", &t); t--; ) {
      |          ~~~~~^~~~~~~~~~
Main.cpp:36:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   36 |         scanf("%d", &k);
      |         ~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Execution timed out 4038 ms 9956 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4038 ms 9956 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4038 ms 9956 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4038 ms 9956 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4038 ms 9956 KB Time limit exceeded
2 Halted 0 ms 0 KB -