제출 #1120502

#제출 시각아이디문제언어결과실행 시간메모리
1120502epicci23저울 (IOI15_scales)C++17
컴파일 에러
0 ms0 KiB
#include "bits/stdc++.h"
#include "scales.h"
//#define int long long
#define all(v) v.begin() , v.end()
#define sz(a) (int)a.size()
using namespace std;

void init(int T){
	
}

void orderCoins(){
  array<int,3> a,b;
  set<int> s;

  for(int i=1;i<=3;i++) s.insert(i);
  a[2] = getHeaviest(1, 2, 3);
  a[0] = getLightest(1, 2, 3);
  s.erase(a[2]);s.erase(a[0]);
  a[1] = *s.begin();
  s.erase(a[1]);
  
  for(int i=4;i<=6;i++) s.insert(i);
  b[2] = getHeaviest(4, 5, 6);
  b[0] = getLightest(4, 5, 6);
  s.erase(b[2]);s.erase(b[0]);
  b[1] = *s.begin();
  s.erase(b[1]);

  int p1 = 0 , p2 = 0 , p3 = 0;
  vector<int> W(6, 0);
  int u = getLightest(a[0], b[0], a[1]);

  if(u == a[0]) W[p3++] = a[p1++];
  else W[p3++] = b[p2++];
  
  while(p1 < 3 && p2 < 3){
  	int u = getMedian(W[0] , a[p1] , b[p2]);
  	if(u == a[p1]) W[p3++] = a[p1++];
  	else W[p3++] = b[p2++];
  }

  while(p1 < 3) W[p3++] = a[p1++];
  while(p2 < 3) W[p3++] = b[p2++];

  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:38:8: warning: declaration of 'u' shadows a previous local [-Wshadow]
   38 |    int u = getMedian(W[0] , a[p1] , b[p2]);
      |        ^
scales.cpp:32:7: note: shadowed declaration is here
   32 |   int u = getLightest(a[0], b[0], a[1]);
      |       ^
scales.cpp:46:10: error: cannot convert 'std::vector<int>' to 'int*'
   46 |   answer(W);
      |          ^
      |          |
      |          std::vector<int>
In file included from scales.cpp:2:
scales.h:10:17: note:   initializing argument 1 of 'void answer(int*)'
   10 | void answer(int W[]);
      |             ~~~~^~~