Submission #39898

#TimeUsernameProblemLanguageResultExecution timeMemory
39898mohammad_kilaniScales (IOI15_scales)C++14
0 / 100
1 ms2024 KiB
#include "scales.h" #include <bits/stdc++.h> using namespace std; void init(int T) { } void orderCoins() { int val[7]; vector< pair<int,int> > v; for(int i=1;i<6;i+=3){ int a = getMedian(i,i+1,i+2); int b = getHeaviest(i,i+1,i+2); int c; if(i != a && i != b) c = i; if(i + 1 != a && i + 1 != b) c = i + 1; if(i + 2 != a && i + 2 != b) c = i + 2; v.push_back(make_pair(0,c)); v.push_back(make_pair(1,a)); v.push_back(make_pair(2,b)); } sort(v.begin(),v.end()); int idx = 0; int w[6]; while(v.size() > 3){ int a = v[0].second; int b = v[1].second; int c = v[2].second; int ans1 = getLightest(a,b,c); w[idx++] = ans1; if(ans1 == a) v[0].first = 100; else if(ans1 == b) v[1].first = 100; else if(ans1 == c) v[2].first = 100; sort(v.begin(),v.end()); v.pop_back(); } int cur1 = getMedian(v[0].second,v[1].second,v[2].second); int cur2 = getHeaviest(v[0].second,v[1].second,v[2].second); int cur3; if(v[0].second != cur1 && v[0].second != cur2) cur3 = v[0].second; if(v[1].second != cur1 && v[1].second != cur2) cur3 = v[1].second; if(v[2].second != cur1 && v[2].second != cur2) cur3 = v[2].second; w[idx++] = cur3; w[idx++] = cur1; w[idx++] = cur2; answer(w); }

Compilation message (stderr)

scales.cpp:6:15: warning: unused parameter 'T' [-Wunused-parameter]
 void init(int T) {
               ^
scales.cpp: In function 'void orderCoins()':
scales.cpp:11:9: warning: unused variable 'val' [-Wunused-variable]
     int val[7];
         ^
scales.cpp:45:20: warning: 'cur3' may be used uninitialized in this function [-Wmaybe-uninitialized]
     w[idx++] = cur3;
                    ^
scales.cpp:20:27: warning: 'c' may be used uninitialized in this function [-Wmaybe-uninitialized]
      v.push_back(make_pair(0,c));
                           ^
#Verdict Execution timeMemoryGrader output
Fetching results...