Submission #1091850

#TimeUsernameProblemLanguageResultExecution timeMemory
1091850MMihalevScales (IOI15_scales)C++14
0 / 100
1 ms604 KiB
#include "scales.h" #include<deque> #include<stack> using namespace std; void init(int T) { /* ... */ } deque<int>q; void fr(int x,int num) { stack<int>s; while(x--){s.push(q.front());q.pop_front();} q.push_front(num); while(s.size()){q.push_front(s.top());s.pop();} } void bk(int x,int num) { stack<int>s; while(x--){s.push(q.back());q.pop_back();} q.push_back(num); while(s.size()){q.push_back(s.top());s.pop();} } void orderCoins() { int W[6]; int a=1; int c=getNextLightest(2,3,4,1); int b=2; if(c==2)b=3; int d=((4^a)^(b^c)); int mid=getMedian(a,b,c); if(mid==a) { //b a c int mid2=getMedian(a,b,d); if(mid2==b) { q.push_back(d);q.push_back(b);q.push_back(a);q.push_back(c); } else if(mid2==d) { q.push_back(b);q.push_back(d);q.push_back(a);q.push_back(c); } else { q.push_back(b);q.push_back(a);q.push_back(c);q.push_back(d); } } else if(mid==c) { //a c b int mid2=getMedian(a,b,d); if(mid2==a) { q.push_back(d);q.push_back(a);q.push_back(c);q.push_back(b); } else if(mid2==d) { q.push_back(a);q.push_back(c);q.push_back(d);q.push_back(b); } else { q.push_back(a);q.push_back(c);q.push_back(b);q.push_back(d); } } else { //c b a int lig=getLightest(a,b,d); if(lig==b) { q.push_back(c);q.push_back(b);q.push_back(d);q.push_back(a); } else q.push_back(c);q.push_back(d);q.push_back(b);q.push_back(a); } for(int cur=5;cur<=6;cur++) { mid=getMedian(q[1],q[q.size()-2],cur); if(mid==cur) { if(cur==5)fr(2,cur); else { int mid2=getMedian(q[1],q[2],cur); if(mid2==cur)fr(2,cur); else fr(3,cur); } } else if(mid==q[1]) { int mid2=getMedian(q[0],q[1],cur); if(mid2==cur)fr(1,cur); else fr(0,cur); } else { int mid2=getMedian(q[q.size()-1],q[q.size()-2],cur); if(mid2==cur)bk(1,cur); else bk(0,cur); } } for(int i=0;i<6;i++)W[i]=q[i]; answer(W); }

Compilation message (stderr)

scales.cpp: In function 'void init(int)':
scales.cpp:5:15: warning: unused parameter 'T' [-Wunused-parameter]
    5 | void init(int T)
      |           ~~~~^
scales.cpp: In function 'void orderCoins()':
scales.cpp:79:9: warning: this 'else' clause does not guard... [-Wmisleading-indentation]
   79 |         else q.push_back(c);q.push_back(d);q.push_back(b);q.push_back(a);
      |         ^~~~
scales.cpp:79:29: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'else'
   79 |         else q.push_back(c);q.push_back(d);q.push_back(b);q.push_back(a);
      |                             ^
#Verdict Execution timeMemoryGrader output
Fetching results...