제출 #691686

#제출 시각아이디문제언어결과실행 시간메모리
691686mychecksedad저울 (IOI15_scales)C++17
71.43 / 100
1 ms304 KiB
#include <bits/stdc++.h> #include <scales.h> using namespace std; void init(int T){ } void answer(int W[]); int getMedian(int A, int B, int C); int getHeaviest(int A, int B, int C); int getLightest(int A, int B, int C); int getNextLightest(int A, int B, int C, int D); void verase(int x, vector<int> &v){ for(int i = 0; i < v.size(); ++i){ if(v[i] == x){ v.erase(v.begin() + i); return; } } } void vinsert(int pos, int val, vector<int> &v){ for(int i = v.size() - 1; i > pos; --i) v[i] = v[i - 1]; v[pos] = val; } void orderCoins() { int W[6]; int mx = getHeaviest(1, 2, 3); int val = getNextLightest(1, 2, 3, 4); vector<int> v(7); vector<bool> used(7); v[3] = mx; used[v[3]] = 1; if(val == mx){ int mn = getLightest(1, 2, 3); v[2] = 4; v[0] = mn; used[v[2]] = used[v[0]] = 1; for(int i = 1; i <= 3; ++i) if(!used[i]) v[1] = i; }else{ used[val] = 1; int k; for(int i = 1; i <= 3; ++i) if(!used[i]) k = i; int med = getMedian(k, v[3], 4); if(med == v[3]){ v[2] = v[3]; v[3] = 4; v[0] = val; v[1] = k; }else if(med == 4){ v[0] = k; v[1] = 4; v[2] = val; }else{ v[0] = 4; v[1] = val; v[2] = k; } } int five1 = getMedian(v[0], v[1], 5); if(five1 == v[0]){ vinsert(0, 5, v); }else if(five1 == 5){ vinsert(1, 5, v); }else{ int five2 = getMedian(v[2], v[3], 5); if(five2 == v[3]){ vinsert(4, 5, v); }else if(five2 == v[2]){ vinsert(2, 5, v); }else{ vinsert(3, 5, v); } } int six1 = getMedian(v[2], v[3], 6); if(six1 == 6){ vinsert(3, 6, v); }else if(six1 == v[2]){ int six2 = getMedian(v[0], v[1], 6); if(six2 == v[0]){ vinsert(0, 6, v); }else if(six2 == v[1]){ vinsert(2, 6, v); }else{ vinsert(1, 6, v); } }else if(six1 == v[3]){ int six2 = getHeaviest(v[0], v[4], 6); if(six2 == 6){ vinsert(5, 6, v); }else{ vinsert(4, 6, v); } } for(int i = 0; i < 6; ++i) W[i] = v[i]; 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 verase(int, std::vector<int>&)':
scales.cpp:17:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |  for(int i = 0; i < v.size(); ++i){
      |                 ~~^~~~~~~~~~
scales.cpp: In function 'void vinsert(int, int, std::vector<int>&)':
scales.cpp:25:23: warning: conversion from 'std::vector<int>::size_type' {aka 'long unsigned int'} to 'int' may change value [-Wconversion]
   25 |  for(int i = v.size() - 1; i > pos; --i) v[i] = v[i - 1];
      |              ~~~~~~~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...