제출 #295579

#제출 시각아이디문제언어결과실행 시간메모리
295579peti1234Scales (IOI15_scales)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; const int c=722; vector<int> sz; int ert[c][6], pos, db, ki, t[3]; bool v[c]; int ask(int a, int b, int c, int h) { int x=0, y=0, z=0; for (int i=0; i<pos; i++) if (v[i]) { t[0]=ert[i][a], t[1]=ert[i][b], t[2]=ert[i][c]; sort(t, t+3); if (a==t[h]) x++; if (b==t[h]) y++; if (c==t[h]) z++; } return max({x, y, z}); } void add(int a, int b, int c, int h, int ans) { for (int i=0; i<pos; i++) if (v[i]) { t[0]=ert[i][a], t[1]=ert[i][b], t[2]=ert[i][c]; sort(t, t+3); if (t[h]!=ans) v[i]=0, db--; } } void orderCoins() { db=0, ki=0; for (int i=0; i<pos; i++) v[i]=1, db++; while(db>1) { int a=1, b=1, c=1, h=0, mini=db, ans=0; for (int x=0; x<6; x++) for (int y=x+1; y<6; y++) for (int z=y+1; z<6; z++) for (int e=0; e<3; e++) { int p=ask(x, y, z, e); if (p<mini) mini=p, a=x, b=y, c=z, h=e; } if (h==0) v=getLightest(a, b, c); if (h==1) v=getMedian(a, b, c); if (h==2) v=getHeaviest(a, b, c); add(a, b, c, h, v); } for (int i=0; i<pos; i++) if (v[i]) ki=i; vector<int> re; re.resize(6); for (int i=0; i<6; i++) re[ert[ki][i]]=i; answer(re); } void init(int t) { for (int i=0; i<6; i++) sz.push_back(i); do { for (int i=0; i<6; i++) ert[pos][i]=sz[i]; pos++; } while(next_permutation(sz.begin(), sz.end())); }

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

scales.cpp: In function 'int ask(int, int, int, int)':
scales.cpp:8:35: warning: declaration of 'c' shadows a global declaration [-Wshadow]
    8 | int ask(int a, int b, int c, int h) {
      |                                   ^
scales.cpp:4:11: note: shadowed declaration is here
    4 | const int c=722;
      |           ^
scales.cpp: In function 'void add(int, int, int, int, int)':
scales.cpp:19:45: warning: declaration of 'c' shadows a global declaration [-Wshadow]
   19 | void add(int a, int b, int c, int h, int ans) {
      |                                             ^
scales.cpp:4:11: note: shadowed declaration is here
    4 | const int c=722;
      |           ^
scales.cpp: In function 'void orderCoins()':
scales.cpp:30:23: warning: declaration of 'c' shadows a global declaration [-Wshadow]
   30 |         int a=1, b=1, c=1, h=0, mini=db, ans=0;
      |                       ^
scales.cpp:4:11: note: shadowed declaration is here
    4 | const int c=722;
      |           ^
scales.cpp:35:21: error: 'getLightest' was not declared in this scope
   35 |         if (h==0) v=getLightest(a, b, c);
      |                     ^~~~~~~~~~~
scales.cpp:36:21: error: 'getMedian' was not declared in this scope
   36 |         if (h==1) v=getMedian(a, b, c);
      |                     ^~~~~~~~~
scales.cpp:37:21: error: 'getHeaviest' was not declared in this scope
   37 |         if (h==2) v=getHeaviest(a, b, c);
      |                     ^~~~~~~~~~~
scales.cpp:38:25: error: invalid conversion from 'bool*' to 'int' [-fpermissive]
   38 |         add(a, b, c, h, v);
      |                         ^
      |                         |
      |                         bool*
scales.cpp:19:42: note:   initializing argument 5 of 'void add(int, int, int, int, int)'
   19 | void add(int a, int b, int c, int h, int ans) {
      |                                      ~~~~^~~
scales.cpp:30:42: warning: unused variable 'ans' [-Wunused-variable]
   30 |         int a=1, b=1, c=1, h=0, mini=db, ans=0;
      |                                          ^~~
scales.cpp:45:5: error: 'answer' was not declared in this scope
   45 |     answer(re);
      |     ^~~~~~
scales.cpp: In function 'void init(int)':
scales.cpp:47:16: warning: declaration of 't' shadows a global declaration [-Wshadow]
   47 | void init(int t) {
      |                ^
scales.cpp:6:29: note: shadowed declaration is here
    6 | int ert[c][6], pos, db, ki, t[3];
      |                             ^
scales.cpp:47:15: warning: unused parameter 't' [-Wunused-parameter]
   47 | void init(int t) {
      |           ~~~~^