제출 #590313

#제출 시각아이디문제언어결과실행 시간메모리
590313AlperenT저울 (IOI15_scales)C++17
0 / 100
1098 ms364 KiB
#include <bits/stdc++.h> #include "scales.h" using namespace std; const int INF = 1e8 + 5; void init(int T) { /* ... */ } struct Rule{ int rt, x; vector<int> param; bool operator < (const Rule &sc) const{ return false; } }; vector<Rule> currules; int findcnt(){ int ans = 0; vector<int> v = {0, 1, 2, 3, 4, 5}; // vector<int> v = {3, 2, 1, 3, 4, 5}; do{ bool flag = true; for(auto rule : currules){ if(!flag) break; if(rule.rt == 1){ int a = rule.param[0], b = rule.param[1], c = rule.param[2]; if(min({v[a], v[b], v[c]}) == v[rule.x]) continue; else flag = false; } else if(rule.rt == 2){ int a = rule.param[0], b = rule.param[1], c = rule.param[2]; if(min({v[a], v[b], v[c]}) != v[rule.x] && max({v[a], v[b], v[c]}) != v[rule.x]) continue; else flag = false; } else if(rule.rt == 3){ int a = rule.param[0], b = rule.param[1], c = rule.param[2]; if(max({v[a], v[b], v[c]}) == v[rule.x]) continue; else flag = false; } else if(rule.rt == 4){ int a = rule.param[0], b = rule.param[1], c = rule.param[2], d = rule.param[3]; vector<int> v2; if(v[a] > v[d]) v2.push_back(a); if(v[b] > v[d]) v2.push_back(b); if(v[c] > v[d]) v2.push_back(c); if(v2.empty()){ if(min({v[a], v[b], v[c]}) == v[rule.x]) continue; else flag = false; } else{ int mn = INF; for(auto x : v2) mn = min(mn, v[x]); if(v[rule.x] == mn) continue; else flag = false; } } } if(flag) ans++; }while(next_permutation(v.begin(), v.end())); return ans == 0 ? INF : ans; } void orderCoins(){ vector<pair<int, Rule>> posrules; while(true){ posrules.clear(); for(int t = 1; t <= 3; t++){ for(int a = 0; a < 6; a++){ for(int b = 0; b < 6; b++){ for(int c = 0; c < 6; c++){ if(a != b && b != c && a != c){ int sum = 0, noinfcnt = 0; currules.push_back({t, a, {a, b, c}}); int x = findcnt(); if(x != INF) sum += x, noinfcnt++; sum += findcnt(); currules.pop_back(); currules.push_back({t, b, {a, b, c}}); x = findcnt(); if(x != INF) sum += x, noinfcnt++; currules.pop_back(); currules.push_back({t, c, {a, b, c}}); x = findcnt(); if(x != INF) sum += x, noinfcnt++; currules.pop_back(); posrules.push_back({noinfcnt == 0 ? INF : sum / noinfcnt, {t, -1, {a, b, c}}}); } } } } } for(int a = 0; a < 6; a++){ for(int b = 0; b < 6; b++){ for(int c = 0; c < 6; c++){ for(int d = 0; d < 6; d++){ if(a != b && a != c && a != d && b != c && b != d && c != d){ int sum = 0, noinfcnt = 0; currules.push_back({4, a, {a, b, c, d}}); int x = findcnt(); if(x != INF) sum += x, noinfcnt++; currules.pop_back(); currules.push_back({4, b, {a, b, c, d}}); x = findcnt(); if(x != INF) sum += x, noinfcnt++; currules.pop_back(); currules.push_back({4, c, {a, b, c, d}}); x = findcnt(); if(x != INF) sum += x, noinfcnt++; currules.pop_back(); posrules.push_back({noinfcnt == 0 ? INF : sum / noinfcnt, {4, -1, {a, b, c, d}}}); } } } } } sort(posrules.begin(), posrules.end()); if(posrules.front().first == 1){ auto rule = posrules.front().second; if(rule.rt == 1){ int x = getLightest(rule.param[0] + 1, rule.param[1] + 1, rule.param[2] + 1); currules.push_back({1, x - 1, {rule.param[0], rule.param[1], rule.param[2]}}); } else if(rule.rt == 2){ int x = getMedian(rule.param[0] + 1, rule.param[1] + 1, rule.param[2] + 1); currules.push_back({2, x - 1, {rule.param[0], rule.param[1], rule.param[2]}}); } else if(rule.rt == 3){ int x = getHeaviest(rule.param[0] + 1, rule.param[1] + 1, rule.param[2] + 1); currules.push_back({3, x - 1, {rule.param[0], rule.param[1], rule.param[2]}}); } else if(rule.rt == 4){ int x = getNextLightest(rule.param[0] + 1, rule.param[1] + 1, rule.param[2] + 1, rule.param[3] + 1); currules.push_back({4, x - 1, {rule.param[0], rule.param[1], rule.param[2], rule.param[3]}}); } break; } else{ auto rule = posrules.front().second; if(rule.rt == 1){ int x = getLightest(rule.param[0] + 1, rule.param[1] + 1, rule.param[2] + 1); currules.push_back({1, x - 1, {rule.param[0], rule.param[1], rule.param[2]}}); } else if(rule.rt == 2){ int x = getMedian(rule.param[0] + 1, rule.param[1] + 1, rule.param[2] + 1); currules.push_back({2, x - 1, {rule.param[0], rule.param[1], rule.param[2]}}); } else if(rule.rt == 3){ int x = getHeaviest(rule.param[0] + 1, rule.param[1] + 1, rule.param[2] + 1); currules.push_back({3, x - 1, {rule.param[0], rule.param[1], rule.param[2]}}); } else if(rule.rt == 4){ int x = getNextLightest(rule.param[0] + 1, rule.param[1] + 1, rule.param[2] + 1, rule.param[3] + 1); currules.push_back({4, x - 1, {rule.param[0], rule.param[1], rule.param[2], rule.param[3]}}); } } } vector<int> v = {0, 1, 2, 3, 4, 5}; do{ bool flag = true; for(auto rule : currules){ if(!flag) break; if(rule.rt == 1){ int a = rule.param[0], b = rule.param[1], c = rule.param[2]; if(min({v[a], v[b], v[c]}) == v[rule.x]) continue; else flag = false; } else if(rule.rt == 2){ int a = rule.param[0], b = rule.param[1], c = rule.param[2]; if(min({v[a], v[b], v[c]}) != v[rule.x] && max({v[a], v[b], v[c]}) != v[rule.x]) continue; else flag = false; } else if(rule.rt == 3){ int a = rule.param[0], b = rule.param[1], c = rule.param[2]; if(max({v[a], v[b], v[c]}) == v[rule.x]) continue; else flag = false; } else if(rule.rt == 4){ int a = rule.param[0], b = rule.param[1], c = rule.param[2], d = rule.param[3]; vector<int> v2; if(v[a] > v[d]) v2.push_back(a); if(v[b] > v[d]) v2.push_back(b); if(v[c] > v[d]) v2.push_back(c); if(v2.empty()){ if(min({v[a], v[b], v[c]}) == v[rule.x]) continue; else flag = false; } else{ int mn = INF; for(auto x : v2) mn = min(mn, v[x]); if(v[rule.x] == mn) continue; else flag = false; } } } if(flag){ vector<pair<int, int>> ansv; for(int i = 0; i < 6; i++) ansv.push_back({v[i], i + 1}); sort(ansv.begin(), ansv.end()); int arr[6]; for(int i = 0; i < 6; i++) arr[i] = ansv[i].second; answer(arr); return; } }while(next_permutation(v.begin(), v.end())); }

컴파일 시 표준 에러 (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 member function 'bool Rule::operator<(const Rule&) const':
scales.cpp:17:34: warning: unused parameter 'sc' [-Wunused-parameter]
   17 |     bool operator < (const Rule &sc) const{
      |                      ~~~~~~~~~~~~^~
#Verdict Execution timeMemoryGrader output
Fetching results...