제출 #1091840

#제출 시각아이디문제언어결과실행 시간메모리
1091840MMihalev저울 (IOI15_scales)C++14
0 / 100
1 ms424 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); } } answer(W); }

컴파일 시 표준 에러 (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...