Submission #755634

#TimeUsernameProblemLanguageResultExecution timeMemory
755634Theo830Scales (IOI15_scales)C++17
55.56 / 100
579 ms508 KiB
#include <bits/stdc++.h> using namespace std; typedef int ll; const ll INF = 1e9+7; const ll MOD = 998244353; typedef pair<ll,ll> ii; #define iii pair<ll,ii> #define f(i,a,b) for(ll i = a;i < b;i++) #define pb push_back #define vll vector<ll> #define F first #define S second #define all(x) (x).begin(), (x).end() #include "scales.h" void init(int T) { } void orderCoins() { int W[6]; vector<int>P; f(i,0,6){ P.pb(i+1); } set<vector<int> >ex; do{ ex.insert(P); } while(next_permutation(all(P))); while(ex.size() > 1){ ll t = 0,a,b,c,d,ans = 0; f(i,0,6){ f(j,i+1,6){ f(k,j+1,6){ ll res = INF; ll cur = 0; for(auto x:ex){ if(x[i] < x[j] && x[i] < x[k]){ } else{ cur++; } } res = min(res,cur); cur = 0; for(auto x:ex){ if(x[j] < x[i] && x[j] < x[k]){ } else{ cur++; } } res = min(res,cur); cur = 0; for(auto x:ex){ if(x[k] < x[i] && x[k] < x[j]){ } else{ cur++; } } res = min(res,cur); if(ans < res){ ans = res; t = 0; a = i; b = j; c = k; } } } } f(i,0,6){ f(j,i+1,6){ f(k,j+1,6){ ll res = INF; ll cur = 0; for(auto x:ex){ if(x[i] > x[j] && x[i] > x[k]){ } else{ cur++; } } res = min(res,cur); cur = 0; for(auto x:ex){ if(x[j] > x[i] && x[j] > x[k]){ } else{ cur++; } } res = min(res,cur); cur = 0; for(auto x:ex){ if(x[k] > x[i] && x[k] > x[j]){ } else{ cur++; } } res = min(res,cur); if(ans < res){ ans = res; t = 2; a = i; b = j; c = k; } } } } f(i,0,6){ f(j,i+1,6){ f(k,j+1,6){ f(u,0,6){ if(u != i && u != j && u != k){ ll res = INF; ll cur = 0; for(auto x:ex){ vector<ii>ar; ar.pb(ii(x[i],i)); ar.pb(ii(x[j],j)); ar.pb(ii(x[u],u)); ar.pb(ii(x[k],k)); bool ok; if(ar.back().S == u){ ok = ar[0].S == i; } else{ f(r,0,3){ if(ar[r].S == u){ ok = ar[r+1].S == i; break; } } } if(!ok){ cur++; } } res = min(res,cur); cur = 0; for(auto x:ex){ vector<ii>ar; ar.pb(ii(x[i],i)); ar.pb(ii(x[j],j)); ar.pb(ii(x[u],u)); ar.pb(ii(x[k],k)); bool ok; if(ar.back().S == u){ ok = ar[0].S == j; } else{ f(r,0,3){ if(ar[r].S == u){ ok = ar[r+1].S == j; break; } } } if(!ok){ cur++; } } res = min(res,cur); cur = 0; for(auto x:ex){ vector<ii>ar; ar.pb(ii(x[i],i)); ar.pb(ii(x[j],j)); ar.pb(ii(x[u],u)); ar.pb(ii(x[k],k)); bool ok; if(ar.back().S == u){ ok = ar[0].S == k; } else{ f(r,0,3){ if(ar[r].S == u){ ok = ar[r+1].S == k; break; } } } if(!ok){ cur++; } } res = min(res,cur); if(ans < res){ ans = res; t = 3; a = i; b = j; c = k; d = u; } } } } } } a++; b++; c++; set<vector<int> >fkale; if(t == 0){ ll pos = getLightest(a,b,c); a--; b--; c--; pos--; for(auto x:ex){ if(x[pos] <= x[a] && x[pos] <= x[b] && x[pos] <= x[c]){ } else{ fkale.insert(x); } } } else if(t == 1){ ll pos = getMedian(a,b,c); a--; b--; c--; pos--; for(auto x:ex){ ll posoi = (x[pos] > x[a]) + (x[pos] > x[b]) + (x[pos] > x[c]); if(posoi != 1){ fkale.insert(x); } } } else if(t == 2){ ll pos = getHeaviest(a,b,c); a--; b--; c--; pos--; for(auto x:ex){ if(x[pos] >= x[a] && x[pos] >= x[b] && x[pos] >= x[c]){ } else{ fkale.insert(x); } } } else{ } for(auto x:fkale){ ex.erase(x); } } vll a = (*ex.begin()); f(i,0,6){ W[a[i]-1] = i+1; } answer(W); }

Compilation message (stderr)

scales.cpp: In function 'void init(int)':
scales.cpp:15:15: warning: unused parameter 'T' [-Wunused-parameter]
   15 | void init(int T) {
      |           ~~~~^
scales.cpp: In function 'void orderCoins()':
scales.cpp:30:24: warning: variable 'd' set but not used [-Wunused-but-set-variable]
   30 |         ll t = 0,a,b,c,d,ans = 0;
      |                        ^
scales.cpp:192:33: warning: 'ok' may be used uninitialized in this function [-Wmaybe-uninitialized]
  192 |                                 if(!ok){
      |                                 ^~
scales.cpp:168:33: warning: 'ok' may be used uninitialized in this function [-Wmaybe-uninitialized]
  168 |                                 if(!ok){
      |                                 ^~
scales.cpp:144:33: warning: 'ok' may be used uninitialized in this function [-Wmaybe-uninitialized]
  144 |                                 if(!ok){
      |                                 ^~
#Verdict Execution timeMemoryGrader output
Fetching results...