제출 #520338

#제출 시각아이디문제언어결과실행 시간메모리
520338silverfish저울 (IOI15_scales)C++17
55.56 / 100
2 ms340 KiB
#include "scales.h" #include <bits/stdc++.h> using namespace std; #define pb push_back #define ar array const int INF = 1000; int ind[6]; map<int, ar<int,6>> ans; int nextl(int a, int b, int c, int d) { int al = 1; a--; b--; c--; d--; if (ind[a] > ind[d] || ind[b] > ind[d] || ind[c] > ind[d]) al = 0; if (al == 1) { if (ind[a] < ind[b] && ind[a] < ind[c]) return a + 1; if (ind[b] < ind[a] && ind[b] < ind[c]) return b + 1; return c + 1; } if (ind[a] > ind[d]) { if ((ind[a] < ind[b] || ind[b] < ind[d]) && (ind[a] < ind[c] || ind[c] < ind[d])) return a + 1; } if (ind[b] > ind[d]) { if ((ind[b] < ind[a] || ind[a] < ind[d]) && (ind[b] < ind[c] || ind[c] < ind[d])) return b + 1; } return c + 1; } int mid(int a, int b, int c) { a--; b--; c--; if (ind[b] < ind[a] && ind[a] < ind[c]) return a + 1; if (ind[c] < ind[a] && ind[a] < ind[b]) return a + 1; if (ind[a] < ind[b] && ind[b] < ind[c]) return b + 1; if (ind[c] < ind[b] && ind[b] < ind[a]) return b + 1; return c + 1; } int heavy(int a, int b, int c) { a--; b--; c--; if (ind[a] > ind[b] && ind[a] > ind[c]) return a + 1; if (ind[b] > ind[a] && ind[b] > ind[c]) return b + 1; return c + 1; } int light(int a, int b, int c) { a--; b--; c--; if (ind[a] < ind[b] && ind[a] < ind[c]) return a + 1; if (ind[b] < ind[a] && ind[b] < ind[c]) return b + 1; return c + 1; } void init(int T) { vector<int> p = {1, 2, 3, 4, 5, 6}; do{ for(int i = 0; i < 6; ++i) ind[p[i]-1] = i; vector<int> q; q.pb(nextl(6,5,1,2)); q.pb(nextl(5,4,6,1)); q.pb(nextl(5,6,2,4)); q.pb(nextl(6,2,1,3)); q.pb(nextl(5,6,4,3)); q.pb(mid(1,2,3)); q.pb(mid(4,5,6)); q.pb(mid(3,4,5)); reverse(q.begin(), q.end()); int mul = 1, cur = 0; for(int x : q){ cur += mul*x; mul *= 10; } int v = 0; mul = 1; for(int i = 0; i < 6; ++i){ ans[cur][i] = p[i]; } }while(next_permutation(p.begin(), p.end())); return; } void orderCoins() { int w[6]; vector<int> q; q.pb(getNextLightest(6,5,1,2)); q.pb(getNextLightest(5,4,6,1)); q.pb(getNextLightest(5,6,2,4)); q.pb(getNextLightest(6,2,1,3)); q.pb(getNextLightest(5,6,4,3)); q.pb(getMedian(1,2,3)); q.pb(getMedian(4,5,6)); q.pb(getMedian(3,4,5)); reverse(q.begin(), q.end()); int mul = 1, cur = 0; for(int x : q){ cur += mul*x; mul *= 10; } for(int i = 0; i < 6; ++i) w[i] = ans[cur][i]; //cout << cur << '\n'; // for(int i = 0; i < 6; ++i) cout << ans[cur][i] << ' '; // cout << '\n'; answer(w); return; }

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

scales.cpp: In function 'void init(int)':
scales.cpp:104:7: warning: unused variable 'v' [-Wunused-variable]
  104 |   int v = 0;
      |       ^
scales.cpp:83:15: warning: unused parameter 'T' [-Wunused-parameter]
   83 | void init(int T) {
      |           ~~~~^
#Verdict Execution timeMemoryGrader output
Fetching results...