Submission #640368

#TimeUsernameProblemLanguageResultExecution timeMemory
640368BenmathScales (IOI15_scales)C++14
55.56 / 100
2 ms212 KiB
#include<bits/stdc++.h> #include "scales.h" using namespace std; int t1; void init(int T) { t1=T; } void orderCoins() { int min1,mid1,max1,min2,mid2,max2; vector<pair<int,int> >v; min1=getLightest(1,2,3); max1=getHeaviest(1,2,3); mid1=6-min1-max1; min2=getLightest(4,5,6); max2=getHeaviest(4,5,6); mid2=15-min2-max2; v.push_back({min1,mid1}); v.push_back({mid1,max1}); v.push_back({min2,mid2}); v.push_back({mid2,max2}); int ro1=min1; int ro2=max1; int t1=0; int c=getMedian(ro1,ro2,min2); if(c==ro1){ v.push_back({min2,ro1}); }else if(c==ro2){ v.push_back({ro2,min2}); t1++; }else{ if(ro1==min1){ int c1=getMedian(ro1,min2,mid1); if(c1==min2){ v.push_back({ro1,min2}); v.push_back({min2,mid1}); }else{ v.push_back({mid1,min2}); v.push_back({min2,ro2}); } ro1=mid1; }else{ v.push_back({ro1,min2}); v.push_back({min2,ro2}); } } if(t1==0){ c=getMedian(ro1,ro2,mid2); if(c==ro1){ v.push_back({mid2,ro1}); }else if(c==ro2){ v.push_back({ro2,mid2}); t1++; }else{ if(ro1==min1){ int c1=getMedian(ro1,mid2,mid1); if(c1==mid2){ v.push_back({ro1,mid2}); v.push_back({mid2,mid1}); }else{ v.push_back({mid1,mid2}); v.push_back({mid2,ro2}); } ro1=mid1; }else{ v.push_back({ro1,mid2}); v.push_back({mid2,ro2}); } } } if(t1==0){ c=getMedian(ro1,ro2,max2); if(c==ro1){ v.push_back({max2,ro1}); }else if(c==ro2){ v.push_back({ro2,max2}); t1++; }else{ if(ro1==min1){ int c1=getMedian(ro1,max2,mid1); if(c1==max2){ v.push_back({ro1,max2}); v.push_back({max2,mid1}); }else{ v.push_back({mid1,max2}); v.push_back({max2,ro2}); } ro1=mid1; }else{ v.push_back({ro1,max2}); v.push_back({max2,ro2}); } } } /* ... */ int W[] = {1, 2, 3, 4, 5, 6}; int t2=0; for(int i=0;i<v.size();i++){ int m1=-1; int m2=-1; for(int j=0;j<6;j++){ if(W[j]==v[i].first){ m1=j; } if(W[j]==v[i].second){ m2=j; } } if(m1>m2){ t2++; } } if(t2==0){ answer(W); } while(next_permutation(W,W+6)){ t2=0; for(int i=0;i<v.size();i++){ int m1=-1; int m2=-1; for(int j=0;j<6;j++){ if(W[j]==v[i].first){ m1=j; } if(W[j]==v[i].second){ m2=j; } } if(m1>m2){ t2++; } } if(t2==0){ answer(W); } } //answer(W); }

Compilation message (stderr)

scales.cpp: In function 'void orderCoins()':
scales.cpp:24:9: warning: declaration of 't1' shadows a global declaration [-Wshadow]
   24 |     int t1=0;
      |         ^~
scales.cpp:4:5: note: shadowed declaration is here
    4 | int t1;
      |     ^~
scales.cpp:99:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   99 |     for(int i=0;i<v.size();i++){
      |                 ~^~~~~~~~~
scales.cpp:120:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  120 |     for(int i=0;i<v.size();i++){
      |                 ~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...