제출 #434716

#제출 시각아이디문제언어결과실행 시간메모리
434716pliam저울 (IOI15_scales)C++14
55.56 / 100
1 ms292 KiB
#include "scales.h" #include <bits/stdc++.h> using namespace std; int known[7]; int prev_[6]; void init(int T) { /* ... */ } void orderCoins() { for(int i=1;i<=6;i++){ known[i]=0; } int W[6]; int l1,m1,h1,l2,m2,h2; l1=getLightest(1,2,3); l2=getLightest(4,5,6); h1=getHeaviest(1,2,3); h2=getHeaviest(4,5,6); for(int i=1;i<=3;i++){ if(i!=l1&&i!=h1) m1=i; } for(int i=4;i<=6;i++){ if(i!=l2&&i!=h2) m2=i; } int a=getHeaviest(l1,h1,h2); if(a==h2){ swap(l1,l2); swap(m1,m2); swap(h1,h2); } prev_[h1]=m1; prev_[m1]=l1; prev_[l1]=0; //now h1 is the heaviest vector<int> sorted; sorted.push_back(l1); sorted.push_back(m1); sorted.push_back(h1); a=getNextLightest(l1,m1,h1,h2); if(a==l1){ sorted.insert(sorted.begin(),h2); sorted.insert(sorted.begin(),m2); sorted.insert(sorted.begin(),l2); for(int i=0;i<=5;i++){ W[i]=sorted[i]; } answer(W); return; } auto it=sorted.begin(); for(int i=0;i<sorted.size();i++,it++){ if(((prev_[a]==0)&&(i==0))||((i>0)&&sorted[i-1]==prev_[a])){ sorted.insert(it,h2); break; } } int b=getNextLightest(l1,m1,h1,m2); if(b==l1){ sorted.insert(sorted.begin(),m2); sorted.insert(sorted.begin(),l2); for(int i=0;i<=5;i++){ W[i]=sorted[i]; } answer(W); return; } it=sorted.begin(); for(int i=0;i<sorted.size();i++,it++){ if(((prev_[b]==0)&&(i==0))||((i>0)&&sorted[i-1]==prev_[b])){ sorted.insert(it,m2); break; } } int c=getNextLightest(l1,m1,h1,l2); it=sorted.begin(); for(int i=0;i<sorted.size();i++,it++){ if(((prev_[c]==0)&&(i==0))||((i>0)&&sorted[i-1]==prev_[c])){ sorted.insert(it,l2); break; } } for(int i=0;i<=5;i++){ W[i]=sorted[i]; } answer(W); }

컴파일 시 표준 에러 (stderr) 메시지

scales.cpp: In function 'void init(int)':
scales.cpp:8:15: warning: unused parameter 'T' [-Wunused-parameter]
    8 | void init(int T) {
      |           ~~~~^
scales.cpp: In function 'void orderCoins()':
scales.cpp:55:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |     for(int i=0;i<sorted.size();i++,it++){
      |                 ~^~~~~~~~~~~~~~
scales.cpp:72:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   72 |     for(int i=0;i<sorted.size();i++,it++){
      |                 ~^~~~~~~~~~~~~~
scales.cpp:80:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   80 |     for(int i=0;i<sorted.size();i++,it++){
      |                 ~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...