제출 #299572

#제출 시각아이디문제언어결과실행 시간메모리
299572mohamedsobhi777저울 (IOI15_scales)C++14
0 / 100
1 ms384 KiB
#include "scales.h"
#include<bits/stdc++.h>

using namespace std ; 

int Te ; 


void init(int T) {
        Te = T ;
    /* ... */
}

void orderCoins() {
    /* ... */
        int W[6] = {1 , 2,  3 , 4, 5 , 6} ; 
        int it = 0 ; 
        vector<int> perm[2] ; 
        perm[0] = { getLightest(1 , 2 , 3) , getMedian(1 , 2, 3) } ;
        perm[0].push_back(6 - perm[0][0] - perm[0][1]) ;

        perm[1] = { getLightest(4 , 5 , 6) , getMedian(4 , 5, 6) } ;
        perm[1].push_back(15 - perm[1][0] - perm[1][1]) ;

        int i = 0 , j = 0 ; 
        while( (i < 2 || j < 2) && max(i, j) < 3 ){
                vector<int> quest = {perm[0][i] , perm[1][j]} ;
                if(i < 2)quest.push_back(perm[0][i+1]) ; 
                else quest.push_back(perm[1][j+1]) ;

                int ans = getLightest(quest[0] , quest[1] , quest[2]) ;
                W[it++] = ans ; 
                if(ans == perm[0][i])
                        i++ ; 
                else j++ ; 
        }
        
        vector<int> rem ;

        while(i < 3)rem.push_back(perm[0][i++]) ; 
        while(j < 3)rem.push_back(perm[1][j++]) ;

        if(i == 3 || j == 3){
                for(int i = 0 ; i < rem.size() ;i++)
                        W[it++] = rem[i] ;
        }else{
                int ans = getMedian(W[0], rem[0] , rem[1]) ; 
                W[it++] = ans ;
                W[it++] = 21 - accumulate(W , W + 6 , 0);
        }

        answer(W);
}

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

scales.cpp: In function 'void orderCoins()':
scales.cpp:44:25: warning: declaration of 'i' shadows a previous local [-Wshadow]
   44 |                 for(int i = 0 ; i < rem.size() ;i++)
      |                         ^
scales.cpp:25:13: note: shadowed declaration is here
   25 |         int i = 0 , j = 0 ;
      |             ^
scales.cpp:44:35: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |                 for(int i = 0 ; i < rem.size() ;i++)
      |                                 ~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...