제출 #60063

#제출 시각아이디문제언어결과실행 시간메모리
60063KieranHorgan저울 (IOI15_scales)C++17
0 / 100
62 ms1044 KiB
#include "scales.h" #include <bits/stdc++.h> using namespace std; void init(int T) { /* ... */ } int gH(vector<int> v, int A, int B, int C) { --A;--B;--C; int H = max(v[A], max(v[B], v[C])); if(v[A]==H) return ++A; if(v[B]==H) return ++B; return ++C; } int gL(vector<int> v, int A, int B, int C) { --A;--B;--C; int L = min(v[A], min(v[B], v[C])); if(v[A]==L) return ++A; if(v[B]==L) return ++B; return ++C; } int gM(vector<int> v, int A, int B, int C) { --A;--B;--C; int H = max(v[A], max(v[B], v[C])); if(v[A]==H) { if(v[B] > v[C]) return ++B; else return ++C; } if(v[B]==H) { if(v[A] > v[C]) return ++A; else return ++C; } if(v[B] > v[A]) return ++B; return ++A; } int gNL(vector<int> v, int A, int B, int C, int D) { --A;--B;--C;--D; vector<pair<int, int>> vp; if(v[A] > v[D]) vp.push_back({v[A], A}); if(v[B] > v[D]) vp.push_back({v[B], B}); if(v[C] > v[D]) vp.push_back({v[C], C}); sort(vp.begin(), vp.end()); if(vp.empty()) return ++D; return ++vp[0].second; } int a[7]; void orderCoins() { /* ... */ // int W[] = {1, 2, 3, 4, 5, 6}; // answer(W); vector<vector<int>> pos; vector<vector<int>> nextPos; vector<int> perm = {1, 2, 3, 4, 5, 6}; do { pos.push_back(perm); } while(next_permutation(perm.begin(), perm.end())); while(pos.size() > 1) { int best = 0; int bestVal = 1000; bool toBreak = 0; for(int A = 1; A <= 6; A++) { for(int B = A+1; B <= 6; B++) { for(int C = B+1; C <= 6; C++) { int cur, curVal; cur = 1*10000 + A*1000 + B*100 + C*10 + 0*1; memset(a, 0, sizeof(a)); for(auto v: pos) a[gH(v, A, B, C)]++; curVal = max(a[A], max(a[B], a[C])); if(curVal < bestVal) bestVal=curVal, best=cur; cur = 2*10000 + A*1000 + B*100 + C*10 + 0*1; memset(a, 0, sizeof(a)); for(auto v: pos) a[gL(v, A, B, C)]++; curVal = max(a[A], max(a[B], a[C])); if(curVal < bestVal) bestVal=curVal, best=cur; cur = 3*10000 + A*1000 + B*100 + C*10 + 0*1; memset(a, 0, sizeof(a)); for(auto v: pos) a[gM(v, A, B, C)]++; curVal = max(a[A], max(a[B], a[C])); if(curVal < bestVal) bestVal=curVal, best=cur; for(int D = 1; D <= 6; D++) if(D != A && D != B && D != C) { memset(a, 0, sizeof(a)); cur = 4*10000 + A*1000 + B*100 + C*10 + D*1; for(auto v: pos) a[gNL(v, A, B, C, D)]++; curVal = max(max(a[A], a[D]), max(a[B], a[C])); if(curVal < bestVal) bestVal=curVal, best=cur; } } } } int t, A, B, C, D; D = best%10; best/=10; C = best%10; best/=10; B = best%10; best/=10; A = best%10; best/=10; t = best%10; best/=10; int val; if(t==1) { val = getHeaviest(A,B,C); for(auto v: pos) if(gH(v, A, B, C) == val) nextPos.push_back(v); } else if(t==2) { val = getLightest(A,B,C); for(auto v: pos) if(gL(v, A, B, C) == val) nextPos.push_back(v); } else if(t==3) { val = getMedian(A,B,C); for(auto v: pos) if(gM(v, A, B, C) == val) nextPos.push_back(v); } else { val = getNextLightest(A,B,C,D); for(auto v: pos) if(gNL(v, A, B, C, D) == val) nextPos.push_back(v); } swap(pos, nextPos); nextPos.clear(); } int ans[] = {0,0,0,0,0,0}; for(int i = 0; i < 6; i++) { ans[pos[0][i]-1] = i+1; } answer(ans); }

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

In file included from grader.c:2:0:
graderlib.c: In function 'void answer(int*)':
graderlib.c:53:5: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
     if (_ghksjhdfkae19ga_ > 1) 
     ^~
graderlib.c:56:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
  for (i = 0; i < 6; i++) {
  ^~~
scales.cpp: In function 'void init(int)':
scales.cpp:5:15: warning: unused parameter 'T' [-Wunused-parameter]
 void init(int T) {
               ^
scales.cpp: In function 'void orderCoins()':
scales.cpp:65:11: warning: unused variable 'toBreak' [-Wunused-variable]
      bool toBreak = 0;
           ^~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...