# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
484790 | imachug | Scales (IOI15_scales) | C++17 | 1 ms | 296 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "scales.h"
#include <bits/stdc++.h>
using namespace std;
const string alphabet = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
#define H(s) getHeaviest((#s)[0] - '0', (#s)[1] - '0', (#s)[2] - '0')
#define L(s) getLightest((#s)[0] - '0', (#s)[1] - '0', (#s)[2] - '0')
#define M(s) getMedian((#s)[0] - '0', (#s)[1] - '0', (#s)[2] - '0')
#define N(s) getNextLightest((#s)[0] - '0', (#s)[1] - '0', (#s)[2] - '0', (#s)[3] - '0')
#define S(fn, args, case_a, case_b, case_c) \
switch_impl( \
fn(args), \
#args, \
[]() { return case_a; }, \
[]() { return case_b; }, \
[]() { return case_c; } \
)
int switch_impl(int val, const char* abc, int (*fn_a)(), int (*fn_b)(), int (*fn_c)()) {
if(val == abc[0] - '0') {
return fn_a();
} else if(val == abc[1] - '0') {
return fn_b();
} else {
return fn_c();
}
}
void init(int T) {
}
void orderCoins() {
int result = (
S(H,123,S(M,456,S(N,2345,S(L,256,S(N,1365,S(N,1463,264351,263451,236451),S(M,146,236145,236415,231645),S(N,1234,263415,263145,264315)),S(N,1236,S(N,1243,524361,352461,523461),S(N,1234,523416,523146,524316),S(M,134,352146,524631,352416)),S(H,234,S(N,1463,643521,634521,364521),S(M,125,624315,645231,624351),S(M,145,623415,623145,623451))),S(L,356,S(N,1265,S(N,1462,364251,362451,326451),S(M,146,326145,326415,321645),S(N,1234,362415,364215,362145)),S(N,1236,S(N,1342,534261,253461,532461),S(M,124,253146,534621,253416),S(N,1234,532416,534216,532146)),S(H,234,S(N,1245,634251,645321,634215),S(N,1462,642531,624531,264531),S(M,145,632415,632145,632451))),S(N,1235,S(N,1236,S(L,123,235461,235461,325461),S(M,124,235146,642351,235416),S(M,124,325146,643251,325416)),S(N,1246,S(N,1263,542631,354261,542361),S(M,134,231546,546231,354621),S(M,135,642315,542316,354216)),S(M,126,S(M,124,321546,543216,254316),S(N,1346,543621,546321,643215),S(N,1263,254631,543261,254361)))),S(N,2346,S(H,256,S(L,234,S(N,1234,652341,652314,652431),S(N,1234,365241,345621,365214),S(N,1253,456231,453621,435621)),S(N,1234,S(N,1253,625341,362541,623541),S(N,1235,623514,623154,625314),S(M,135,362154,625431,362514)),S(N,1346,S(N,1453,245361,234561,243561),S(M,145,234156,231456,234516),S(N,1235,243516,243156,245316))),S(H,356,S(L,234,S(N,1234,265341,265314,245631),S(N,1234,653241,653421,653214),S(N,1352,456321,452631,425631)),S(N,1234,S(N,1352,635241,263541,632541),S(M,125,263154,635421,263514),S(N,1235,632514,635214,632154)),S(N,1246,S(N,1452,345261,324561,342561),S(M,145,324156,321456,324516),S(N,1235,342516,345216,342156))),S(N,1235,S(N,1234,S(L,123,236541,236541,326541),S(N,1256,423561,423516,236514),S(N,1256,432561,432516,326514)),S(M,135,S(N,1256,236154,423156,231654),S(M,126,452316,654231,452361),S(N,1236,435261,365421,435216)),S(M,125,S(N,1256,326154,432156,321654),S(M,126,453216,654321,453261),S(N,1236,425361,425316,265431)))),S(N,2345,S(H,256,S(L,234,S(N,1234,562341,562314,562431),S(N,1234,356241,346521,356214),S(N,1263,465231,463521,436521)),S(N,1345,S(N,1463,246351,234651,243651),S(M,146,234165,231465,234615),S(N,1236,243615,243165,246315)),S(N,1234,S(N,1263,526341,352641,523641),S(N,1236,523614,523164,526314),S(M,136,352164,526431,352614))),S(H,356,S(L,234,S(N,1234,256341,256314,246531),S(N,1234,563241,563421,563214),S(N,1362,465321,462531,426531)),S(N,1245,S(N,1462,346251,324651,342651),S(M,146,324165,321465,324615),S(N,1236,342615,346215,342165)),S(N,1234,S(N,1362,536241,253641,532641),S(M,126,253164,536421,253614),S(N,1236,532614,536214,532164))),S(N,1236,S(N,1234,S(L,123,235641,235641,325641),S(N,1265,423651,423615,235614),S(N,1265,432651,432615,325614)),S(M,136,S(N,1265,235164,423165,231564),S(M,125,462315,564231,462351),S(N,1235,436251,356421,436215)),S(M,126,S(N,1265,325164,432165,321564),S(M,125,463215,564321,463251),S(N,1235,426351,426315,256431))))),S(M,456,S(N,1345,S(L,156,S(N,1452,S(N,1463,164352,163452,136452),S(N,1236,132645,136245,163245),S(N,1463,164325,163425,136425)),S(N,1236,S(N,1234,513246,513426,514326),S(N,1243,351462,514362,513462),S(N,1342,514632,351426,351246)),S(H,134,S(N,1463,643512,634512,364512),S(M,125,645132,614325,614352),S(N,1452,613452,613245,613425))),S(L,356,S(N,1265,S(N,1462,316425,316245,312645),S(M,146,361452,364152,316452),S(N,1234,364125,361425,361245)),S(N,1236,S(M,124,534612,153246,153426),S(M,134,531462,153462,534162),S(N,1234,534126,531426,531246)),S(H,134,S(N,1245,645312,634152,634125),S(M,146,614532,641532,164532),S(N,1452,631452,631245,631425))),S(N,1235,S(N,1246,S(H,134,354612,546132,132546),S(N,1263,354162,541632,541362),S(H,135,354126,541326,641325)),S(N,1236,S(M,124,641352,135246,135426),S(L,123,135462,135462,315462),S(M,124,643152,315246,315426)),S(M,126,S(N,1346,543612,546312,643125),S(M,124,543126,312546,154326),S(N,1263,543162,154632,154362)))),S(N,1346,S(H,156,S(L,134,S(N,1234,651324,651342,651432),S(N,1234,345612,365142,365124),S(N,1253,453612,456132,435612)),S(N,1234,S(N,1235,613254,613524,615324),S(N,1253,361542,615342,613542),S(N,1352,615432,361524,361254)),S(N,1562,S(N,1453,145362,134562,143562),S(N,1234,132456,134256,143256),S(N,1453,145326,134526,143526))),S(H,356,S(L,134,S(N,1234,165324,165342,145632),S(N,1234,653412,653142,653124),S(M,135,451632,456312,415632)),S(N,1234,S(M,125,635412,163254,163524),S(M,135,631542,163542,635142),S(N,1235,635124,631524,631254)),S(N,1246,S(N,1452,314526,312456,314256),S(M,145,341562,314562,345162),S(N,1235,345126,341526,341256))),S(N,1235,S(H,135,S(N,1236,365412,435162,435126),S(M,126,654132,451326,451362),S(N,1256,413256,136254,132654)),S(N,1234,S(N,1256,413526,413562,136524),S(L,123,136542,136542,316542),S(N,1256,431526,431562,316524)),S(M,125,S(M,126,654312,453126,453162),S(N,1256,431256,316254,312654),S(N,1236,415326,415362,165432)))),S(N,1345,S(H,156,S(L,134,S(N,1234,561324,561342,561432),S(N,1234,346512,356142,356124),S(N,1263,463512,465132,436512)),S(N,1562,S(N,1463,146352,134652,143652),S(N,1463,146325,134625,143625),S(N,1234,132465,134265,143265)),S(N,1234,S(N,1236,513264,513624,516324),S(N,1263,351642,516342,513642),S(N,1362,516432,351624,351264))),S(H,356,S(L,134,S(N,1234,156324,156342,146532),S(N,1234,563412,563142,563124),S(M,136,461532,465312,416532)),S(N,1245,S(N,1462,314625,312465,314265),S(M,146,341652,314652,346152),S(N,1236,346125,341625,341265)),S(N,1234,S(M,126,536412,153264,153624),S(M,136,531642,153642,536142),S(N,1236,536124,531624,531264))),S(N,1236,S(H,136,S(N,1235,356412,436152,436125),S(M,125,564132,461325,461352),S(N,1265,413265,135264,132564)),S(N,1234,S(N,1265,413625,413652,135624),S(L,123,135642,135642,315642),S(N,1265,431625,431652,315624)),S(M,126,S(M,125,564312,463125,463152),S(N,1265,431265,315264,312564),S(N,1235,416325,416352,156432))))),S(M,456,S(N,1245,S(L,156,S(N,1453,S(N,1462,164253,162453,126453),S(N,1236,123645,162345,126345),S(N,1462,164235,162435,126435)),S(N,1236,S(N,1234,512346,514236,512436),S(N,1243,514623,251436,251346),S(M,124,251463,512463,514263)),S(H,124,S(N,1462,642513,624513,264513),S(M,135,645123,614235,614253),S(N,1453,612453,612345,612435))),S(L,256,S(N,1365,S(N,1463,216435,216345,213645),S(M,146,261453,264153,216453),S(N,1234,264135,261345,261435)),S(N,1236,S(N,1243,152436,524613,152346),S(N,1234,524136,521346,521436),S(M,124,521463,152463,524163)),S(H,124,S(N,1345,645213,624153,624135),S(M,146,614523,641523,164523),S(N,1453,621453,621345,621435))),S(N,1235,S(N,1246,S(H,124,254613,546123,123546),S(N,1263,541623,254163,254136),S(N,1356,641235,541263,541236)),S(N,1246,S(N,1263,154263,542613,154236),S(H,124,546213,154623,213546),S(N,1356,642135,542163,542136)),S(N,1236,S(M,134,641253,125346,125436),S(M,134,642153,215346,215436),S(L,123,125463,215463,125463)))),S(N,1246,S(H,156,S(L,124,S(N,1234,651234,651423,651243),S(N,1234,245613,265134,265143),S(M,125,456123,452613,425613)),S(N,1234,S(N,1235,612354,615234,612534),S(N,1253,615423,261534,261354),S(M,125,261543,612543,615243)),S(N,1563,S(N,1452,145263,124563,142563),S(N,1234,123456,142356,124356),S(N,1452,145236,124536,142536))),S(H,256,S(L,124,S(N,1234,165234,145623,165243),S(N,1234,652413,652134,652143),S(M,125,451623,456213,415623)),S(N,1234,S(N,1253,162534,625413,162354),S(N,1235,625134,621354,621534),S(M,125,621543,162543,625143)),S(N,1346,S(N,1453,214536,213456,214356),S(M,145,241563,214563,245163),S(N,1235,245136,241356,241536))),S(N,1235,S(H,125,S(N,1236,265413,425136,425163),S(M,136,654123,451236,451263),S(N,1356,412356,126354,123654)),S(H,125,S(M,136,654213,452136,452163),S(N,1236,415236,165423,415263),S(N,1356,421356,216354,213654)),S(N,1234,S(N,1356,412536,412563,126534),S(N,1356,421536,421563,216534),S(L,123,126543,216543,126543)))),S(N,1245,S(H,156,S(L,124,S(N,1234,561234,561423,561243),S(N,1234,246513,256134,256143),S(M,126,465123,462513,426513)),S(N,1563,S(N,1462,146253,124653,142653),S(N,1462,146235,124635,142635),S(N,1234,123465,142365,124365)),S(N,1234,S(N,1236,512364,516234,512634),S(N,1263,516423,251634,251364),S(M,126,251643,512643,516243))),S(H,256,S(L,124,S(N,1234,156234,146523,156243),S(N,1234,562413,562134,562143),S(M,126,461523,465213,416523)),S(N,1345,S(N,1463,214635,213465,214365),S(M,146,241653,214653,246153),S(N,1236,246135,241365,241635)),S(N,1234,S(N,1263,152634,526413,152364),S(N,1236,526134,521364,521634),S(M,126,521643,152643,526143))),S(N,1236,S(H,126,S(N,1235,256413,426135,426153),S(M,135,564123,461235,461253),S(N,1365,412365,125364,123564)),S(H,126,S(M,135,564213,462135,462153),S(N,1235,416235,156423,416253),S(N,1365,421365,215364,213564)),S(N,1234,S(N,1365,412635,412653,125634),S(N,1365,421635,421653,215634),S(L,123,125643,215643,125643))))))
);
int w[6];
for(int i = 5; i >= 0; i--) {
w[i] = result % 10;
result /= 10;
}
answer(w);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |