제출 #237900

#제출 시각아이디문제언어결과실행 시간메모리
237900crossing0verScales (IOI15_scales)C++17
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h> #define ll long long //#include "scales.h" using namespace std; vector<vector<int> > all,sall; vector<vector<int> > Left1,Left; vector<int> g,to_ask; bool vis[7],cmp[7][7],lets[7][7] , Rcmp[7][7]; int oper; void G(int c) { if (c == 6) { Left1.push_back(g); return; } for (int i = 1; i <= 6; i++) { if (!vis[i]) { g.push_back(i); vis[i] = 1; G(c+1); vis[i] = 0; g.pop_back(); } } } void init(int T) { for (int i = 1; i<=6;i++) for (int j = i + 1; j <= 6; j++) for (int k = j+1;k <=6;k++) { all.push_back({i,j,k}); for (int f = 1; f <= 6; f++) { if (f != j && f != i && f != k) sall.push_back({i,j,j,f}); } } G(0); Left = Left1; //cout << all.size() << ' ' << Left.size(); } int calculate() { int cnt = 0; for (auto g:Left) { bool flag = 1; for (int i = 0; i < 6; i++) for (int j = i+1; j < 6; j++) { if ( cmp[g[i]][g[j]] == 1 ) flag = 0; } if (flag) cnt++; } return cnt; } void lower(int k,int j) { cmp[k][j] = -1; cmp[j][k] = 1; for (int i = 1; i <= 6 ;i++) { if (!Rcmp[k][i] && cmp[j][i] == -1) { cmp[k][i] = -1; cmp[i][k] = 1; } if (!Rcmp[j][i] && cmp[k][j] == 1) { cmp[j][i] = 1; cmp[i][j] = -1; } } } void process(int k) { for (int i = 1; i <= 6; i++) { cmp[k][i] = Rcmp[k][i]; cmp[i][k] = Rcmp[i][k]; } } void GO(int k,int j) { Rcmp[k][j] = -1; Rcmp[j][k] = 1; for (int i = 1; i <= 6 ;i++) { if (Rcmp[j][i] == -1) { Rcmp[k][i] = -1; Rcmp[i][k] = 1; } if (Rcmp[k][j] == 1) { Rcmp[j][i] = 1; Rcmp[i][j] = -1; } } } void minimize(int &total_ans,int &c,int type,vector<int> v) { if (total_ans > c) { total_ans = c; to_ask = v; oper = type; } } void cnt_min(){ int total_ans = 10000; for (auto v : all) { int a[3]; memset(a,0,sizeof a); vector<int> h; int c = 0; for (int ans : v) { h = v; h.erase(find(h.begin(),h.end(),ans)); process(ans); process(h[0]); process(h[1]); if (cmp[ans][h[0]] == 1 || cmp[ans][h[1]] == 1) continue; lower(ans,h[0]); lower(ans,h[1]); if (cmp[h[0]][h[1]] == 0) { lower(h[0],h[1]); c = max( calculate(),c); process(h[0]); process(h[1]); lower(ans,h[0]); lower(ans,h[1]); lower(h[1],h[0]); c = max( calculate(),c); } else c = max(c,calculate()); process(ans); process(h[0]); process(h[1]); } minimize(total_ans,c,0,v); c = 0; for (int ans : v) { h = v; h.erase(find(h.begin(),h.end(),ans)); process(ans); process(h[0]); process(h[1]); if (cmp[ans][h[0]] == -1 || cmp[ans][h[1]] == -1) continue; lower(h[0],ans); lower(h[1],ans); if (cmp[h[0]][h[1]] == 0) { lower(h[0],h[1]); c = max( calculate(),c); process(h[0]); process(h[1]); lower(h[0],ans); lower(h[1],ans); lower(h[1],h[0]); c = max( calculate(),c); } else c = max(c,calculate()); process(ans); process(h[0]); process(h[1]); } minimize(total_ans,c,1,v); c = 0; for (int ans : v) { h = v; h.erase(find(h.begin(),h.end(),ans)); process(ans); process(h[0]); process(h[1]); if ( (cmp[ans][h[0]] == -1 && cmp[ans][h[1]] == -1) || (cmp[ans][h[0]] == 1 && cmp[ans][h[1]] == 1) ) continue; if (cmp[h[0]][h[1]] != 0) { if (cmp[h[0]][h[1]] == 1) lower(ans,h[0]); else lower(ans,h[1]); c = max(c,calculate()); } else { if (cmp[ans][h[0]] != 0) { if (cmp[ans][h[0]] == -1) lower(h[1],ans); else lower(ans,h[1]); c = max(c,calculate()); } else if (cmp[ans][h[1]] != 0){ if (cmp[ans][h[1]] == -1) lower(h[0],ans); else lower(ans,h[0]); c = max(c,calculate()); } else { lower(ans,h[0]); lower(h[1],ans); c = max(c,calculate()); process(ans); process(h[0]); process(h[1]); lower(ans,h[1]); lower(h[0],ans); c = max(c,calculate()); } } process(ans); process(h[0]); process(h[1]); } minimize(total_ans,c,2,v); c = 0; } /* for (auto v:sall) { vector<int> h; }*/ } // 0 getLightest(A, B, C) 1 getHeaviest(A, B, C) ,2 getMedian(A, B, C) 3 getNextLightest(A, B, C, D) void orderCoins() { Left = Left1; /* ... */ while(true) { cnt_min(); vector<int> v = to_ask; int a; if (oper == 0) { a = getLightest(v[0],v[1],v[2]); for (int i:v) if (a != i) GO(a,i); } if (oper == 1) { a = getHeaviest(v[0],v[1],v[2]); for (int i:v) if (a != i) GO(i,a); } if (oper == 2) { a = greatest(v[0],v[1],v[2]); } if (oper == 0) { a = getMedian(v[0],v[1],v[2]); } for (int i = 1; i <= 6; i++) process(i); vector<vector<int> > g; for (auto v:Left) { bool flag = 1; for (int i = 0; i < 6; i++) for (int j = i+1; j < 6; j++) { if ( cmp[v[i]][v[j]] == 1 ) flag = 0; } if (flag) g.push_back(v); } Left = g; if (Left.size() == 1){ int W[6]; for (int i : Left[0]) W[i] = i; answer(W); return; } } } int main(){ init(5); cnt_min(); }

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

scales.cpp: In function 'void init(int)':
scales.cpp:26:15: warning: unused parameter 'T' [-Wunused-parameter]
 void init(int T) {
               ^
scales.cpp: In function 'int calculate()':
scales.cpp:43:13: warning: declaration of 'g' shadows a global declaration [-Wshadow]
   for (auto g:Left) {
             ^
scales.cpp:7:13: note: shadowed declaration is here
 vector<int> g,to_ask;
             ^
scales.cpp: In function 'void lower(int, int)':
scales.cpp:59:32: warning: comparison of constant '-1' with boolean expression is always false [-Wbool-compare]
   if (!Rcmp[k][i] && cmp[j][i] == -1) {
                      ~~~~~~~~~~^~~~~
scales.cpp: In function 'void GO(int, int)':
scales.cpp:81:18: warning: comparison of constant '-1' with boolean expression is always false [-Wbool-compare]
   if (Rcmp[j][i] == -1) {
       ~~~~~~~~~~~^~~~~
scales.cpp: In function 'void cnt_min()':
scales.cpp:142:24: warning: comparison of constant '-1' with boolean expression is always false [-Wbool-compare]
     if (cmp[ans][h[0]] == -1 || cmp[ans][h[1]] == -1) continue;
         ~~~~~~~~~~~~~~~^~~~~
scales.cpp:142:48: warning: comparison of constant '-1' with boolean expression is always false [-Wbool-compare]
     if (cmp[ans][h[0]] == -1 || cmp[ans][h[1]] == -1) continue;
                                 ~~~~~~~~~~~~~~~^~~~~
scales.cpp:172:26: warning: comparison of constant '-1' with boolean expression is always false [-Wbool-compare]
     if ( (cmp[ans][h[0]] == -1 && cmp[ans][h[1]] == -1) || (cmp[ans][h[0]] == 1 && cmp[ans][h[1]] == 1) ) continue;
           ~~~~~~~~~~~~~~~^~~~~
scales.cpp:172:50: warning: comparison of constant '-1' with boolean expression is always false [-Wbool-compare]
     if ( (cmp[ans][h[0]] == -1 && cmp[ans][h[1]] == -1) || (cmp[ans][h[0]] == 1 && cmp[ans][h[1]] == 1) ) continue;
                                   ~~~~~~~~~~~~~~~^~~~~
scales.cpp:181:25: warning: comparison of constant '-1' with boolean expression is always false [-Wbool-compare]
      if (cmp[ans][h[0]] == -1)
          ~~~~~~~~~~~~~~~^~~~~
scales.cpp:187:25: warning: comparison of constant '-1' with boolean expression is always false [-Wbool-compare]
      if (cmp[ans][h[1]] == -1)
          ~~~~~~~~~~~~~~~^~~~~
scales.cpp: In function 'void orderCoins()':
scales.cpp:229:10: error: 'getLightest' was not declared in this scope
      a = getLightest(v[0],v[1],v[2]);
          ^~~~~~~~~~~
scales.cpp:229:10: note: suggested alternative: 'gettext'
      a = getLightest(v[0],v[1],v[2]);
          ^~~~~~~~~~~
          gettext
scales.cpp:233:10: error: 'getHeaviest' was not declared in this scope
      a = getHeaviest(v[0],v[1],v[2]);
          ^~~~~~~~~~~
scales.cpp:237:10: error: 'greatest' was not declared in this scope
      a = greatest(v[0],v[1],v[2]);
          ^~~~~~~~
scales.cpp:237:10: note: suggested alternative: 'gettext'
      a = greatest(v[0],v[1],v[2]);
          ^~~~~~~~
          gettext
scales.cpp:240:10: error: 'getMedian' was not declared in this scope
      a = getMedian(v[0],v[1],v[2]);
          ^~~~~~~~~
scales.cpp:240:10: note: suggested alternative: 'getdelim'
      a = getMedian(v[0],v[1],v[2]);
          ^~~~~~~~~
          getdelim
scales.cpp:243:23: warning: declaration of 'g' shadows a global declaration [-Wshadow]
  vector<vector<int> > g;
                       ^
scales.cpp:7:13: note: shadowed declaration is here
 vector<int> g,to_ask;
             ^
scales.cpp:244:12: warning: declaration of 'v' shadows a previous local [-Wshadow]
  for (auto v:Left) {
            ^
scales.cpp:226:17: note: shadowed declaration is here
     vector<int> v = to_ask;
                 ^
scales.cpp:256:4: error: 'answer' was not declared in this scope
    answer(W);
    ^~~~~~
scales.cpp:256:4: note: suggested alternative: 'lower'
    answer(W);
    ^~~~~~
    lower