Submission #593877

#TimeUsernameProblemLanguageResultExecution timeMemory
593877davi_bartScales (IOI15_scales)C++17
55.56 / 100
1 ms296 KiB
#pragma GCC optimize("O3") #include <bits/stdc++.h> #include "scales.h" using namespace std; #define ll long long // #define int ll #define fi first #define se second #define ld long double #define pb push_back mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); void init(int T) { } void orderCoins() { vector<int> v = {1, 2, 3, 4, 5, 6}; int x = getLightest(1, 2, 3); swap(v[0], v[x - 1]); int y = getLightest(4, 5, 6); swap(v[3], v[y - 1]); int z = getMedian(v[0], v[3], v[1]); if (z == v[1]) { v = {v[0], v[1], v[3], v[2], v[4], v[5]}; x = getLightest(v[1], v[2], v[3]); if (x == v[3]) { swap(v[1], v[3]); swap(v[2], v[3]); } else { x = getLightest(v[3], v[4], v[5]); if (x == v[5]) swap(v[3], v[5]); x = getMedian(v[2], v[3], v[4]); if (x == v[2]) swap(v[2], v[3]); else if (x == v[4]) swap(v[3], v[4]); } x = getHeaviest(v[0], v[4], v[5]); if (x == v[4]) swap(v[4], v[5]); } else { if (z == v[0]) { v = {v[3], v[0], v[1], v[2], v[4], v[5]}; x = getLightest(v[1], v[4], v[5]); bool ok = 0; if (x == v[4]) { v = {v[0], v[4], v[1], v[2], v[3], v[5]}; ok = 1; } else if (x == v[5]) { v = {v[0], v[5], v[1], v[2], v[3], v[4]}; ok = 1; } if (ok) { // for (int x : v) cout << x << " "; // cout << endl; x = getMedian(v[2], v[3], v[5]); if (x == v[2]) { v = {v[0], v[1], v[5], v[2], v[3], v[4]}; x = getHeaviest(v[0], v[4], v[5]); if (x == v[4]) swap(v[4], v[5]); answer(v.data()); return; } if (x == v[3]) { x = getMedian(v[3], v[4], v[5]); if (x == v[3]) v = {v[0], v[1], v[2], v[4], v[3], v[5]}; else if (x == v[4]) v = {v[0], v[1], v[2], v[3], v[4], v[5]}; else if (x == v[5]) v = {v[0], v[1], v[2], v[3], v[5], v[4]}; answer(v.data()); return; } if (x == v[5]) { x = getMedian(v[3], v[4], v[5]); if (x == v[3]) v = {v[0], v[1], v[2], v[5], v[3], v[4]}; else if (x == v[4]) v = {v[0], v[1], v[2], v[5], v[4], v[3]}; else if (x == v[5]) v = {v[0], v[1], v[2], v[4], v[5], v[3]}; answer(v.data()); return; } } } else if (z == v[3]) { v = {v[0], v[3], v[1], v[2], v[4], v[5]}; x = getLightest(v[1], v[2], v[3]); if (x == v[3]) v = {v[0], v[3], v[1], v[2], v[4], v[5]}; } // for (int x : v) cout << x << " "; // cout << endl; // x = getMedian(v[1], v[2], v[3]); // if (x == v[3]) swap(v[2], v[1]); for (int j = 3; j >= 2; j--) { for (int i = j; i < 4; i++) { int x = getLightest(v[i], v[i + 1], v[i + 2]); if (x == v[i + 1]) swap(v[i + 1], v[i]); else if (x == v[i + 2]) swap(v[i + 2], v[i]); } } int x = getHeaviest(v[0], v[4], v[5]); if (x == v[4]) swap(v[4], v[5]); } answer(v.data()); }

Compilation message (stderr)

scales.cpp: In function 'void init(int)':
scales.cpp:13:15: warning: unused parameter 'T' [-Wunused-parameter]
   13 | void init(int T) {
      |           ~~~~^
scales.cpp: In function 'void orderCoins()':
scales.cpp:100:21: warning: declaration of 'x' shadows a previous local [-Wshadow]
  100 |                 int x = getLightest(v[i], v[i + 1], v[i + 2]);
      |                     ^
scales.cpp:17:9: note: shadowed declaration is here
   17 |     int x = getLightest(1, 2, 3);
      |         ^
scales.cpp:107:13: warning: declaration of 'x' shadows a previous local [-Wshadow]
  107 |         int x = getHeaviest(v[0], v[4], v[5]);
      |             ^
scales.cpp:17:9: note: shadowed declaration is here
   17 |     int x = getLightest(1, 2, 3);
      |         ^
#Verdict Execution timeMemoryGrader output
Fetching results...