Submission #619591

#TimeUsernameProblemLanguageResultExecution timeMemory
619591mdn2002Scales (IOI15_scales)C++14
55.56 / 100
1 ms212 KiB
#include "scales.h" #include<bits/stdc++.h> using namespace std; void init(int T) { /* ... */ } void orderCoins() { int l1 = getLightest ( 1 , 2 , 3 ) , l2 = getLightest ( 4 , 5 , 6 ) , l , n = 6; map < int , int > ans; for ( int i = 1 ; i <= n ; i ++ ) { if ( i != l1 && i != l2 ) { l = getLightest ( l1 , l2 , i ); ans [1] = l; break; } } vector < int > nxt; int cn; if ( l1 == l ) { cn = l2; for ( int i = 1 ; i <= 3 ; i ++ ) { if ( l != i ) nxt . push_back ( i ); } } if ( l2 == l ) { cn = l1; for ( int i = 4 ; i <= 6 ; i ++ ) { if ( l != i ) nxt . push_back ( i ); } } int l22 = getLightest ( nxt [0] , nxt [1] , cn ); ans [2] = l22; if ( l22 == cn ) { set < int > s; for ( int i = 1 ; i <= 6 ; i ++ ) { if ( i == l || i == l22 ) continue; s . insert ( i ); } int l33 = getNextLightest ( l , l22 , * s . begin () , * -- s . end () ); int a = * s . begin () , b = * -- s . end () , c = -1 , d; if ( l33 == a ) swap ( a , b ); for ( int i = 1 ; i <= 6 ; i ++ ) { if ( i == a || i == b || i == l || i == l22 ) continue; if ( c == -1 ) c = i; else d = i; } int ltt = getLightest ( a , c , d ); ans [3] = ltt; if ( ltt == a ) { int lttt = getLightest ( b , c , d ); int hvvv = getHeaviest ( b , c , d ); ans [4] = lttt , ans [6] = hvvv; for ( int i = 1 ; i <= n ; i ++ ) { if ( i == lttt || i == hvvv ) continue; if ( i != b && i != c && i != d ) continue; ans [5] = i; } } else { int hvv = getHeaviest ( a , c , d ); if ( ltt == c ) c = d; if ( hvv == a ) { ans [4] = c; ans [5] = a; ans [6] = b; } else { int middd = getMedian ( a , b , c ); if ( middd == a ) { ans [4] = c; ans [5] = a; ans [6] = b; } if ( middd == b ) { ans [4] = a; ans [5] = b; ans [6] = c; } if ( middd == c ) { ans [4] = a; ans [5] = c; ans [6] = b; } } } } else { int mid , fuck; if ( nxt [0] == l22 ) nxt . erase ( nxt . begin () ); if ( nxt [1] == l22 ) nxt . pop_back (); for ( int i = 1 ; i <= n ; i ++ ) { if ( i == l ) continue; if ( i == l22 ) continue; if ( i == nxt [0] ) continue; if ( i == cn ) continue; mid = getMedian ( nxt [0] , cn , i ); if ( mid == nxt [0] ) { ans [3] = cn; fuck = i; } if ( mid == cn ) { ans [3] = nxt [0]; ans [4] = cn; } if ( mid == i ) { ans [3] = cn; fuck = nxt [0]; nxt [0] = i; } break; } set < int > s; for ( int i = 1 ; i <= 6 ; i ++ ) s . insert ( i ); for ( int i = 1 ; i <= 4 ; i ++ ) { if ( ans [i] == 0 ) break; s . erase ( s . lower_bound ( ans [i] ) ); } int midd; if ( s . size () == 3 ) { midd = getMedian ( * s . begin () , * ++ s . begin () , * ++ ++ s . begin () ); int in; for ( auto x : s ) { if ( x != nxt [0] && x != fuck ) in = x; } if ( midd == nxt [0] ) { ans [4] = in; ans [5] = nxt [0]; ans [6] = fuck; } if ( midd == fuck ) { ans [4] = nxt [0]; ans [5] = fuck; ans [6] = in; } if ( midd == in ) { ans [4] = nxt [0]; ans [5] = in; ans [6] = fuck; } } else { midd = getMedian ( * s . begin () , * ++ s . begin () , l ); int in; for ( auto x : s ) { if ( x != midd ) in = x; } ans [5] = midd; ans [6] = in; } } int W[] = { ans [1] , ans [2] , ans [3] , ans [4] , ans [5] , ans [6] }; answer(W); }

Compilation message (stderr)

scales.cpp: In function 'void init(int)':
scales.cpp:4:15: warning: unused parameter 'T' [-Wunused-parameter]
    4 | void init(int T) {
      |           ~~~~^
scales.cpp: In function 'void orderCoins()':
scales.cpp:183:21: warning: 'in' may be used uninitialized in this function [-Wmaybe-uninitialized]
  183 |             ans [6] = in;
scales.cpp:170:25: warning: 'in' may be used uninitialized in this function [-Wmaybe-uninitialized]
  170 |                 ans [5] = in;
scales.cpp:153:35: warning: 'fuck' may be used uninitialized in this function [-Wmaybe-uninitialized]
  153 |                 if ( x != nxt [0] && x != fuck ) in = x;
      |                      ~~~~~~~~~~~~~^~~~~~~~~~~~
scales.cpp:68:44: warning: 'd' may be used uninitialized in this function [-Wmaybe-uninitialized]
   68 |                 if ( i != b && i != c && i != d ) continue;
      |                                          ~~^~~~
scales.cpp:126:13: warning: 'cn' may be used uninitialized in this function [-Wmaybe-uninitialized]
  126 |             if ( mid == cn )
      |             ^~
scales.cpp:46:13: warning: 'l' may be used uninitialized in this function [-Wmaybe-uninitialized]
   46 |             if ( i == l || i == l22 ) continue;
      |             ^~
#Verdict Execution timeMemoryGrader output
Fetching results...