# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
60802 | istlemin | Scales (IOI15_scales) | C++14 | 4 ms | 620 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "scales.h"
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i = a; i<int(b);++i)
#define all(v) v.begin(),v.end()
#define sz(v) v.size()
#define trav(a,c) for(auto a: c)
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pii;
vector<tuple<ll,ll,ll,ll> > heaviestOps;
ll heaviest(ll a,ll b,ll c){
if(a==b||b==c||c==a) return -1;
ll res = getHeaviest(a+1,b+1,c+1)-1;
//heaviestOps.emplace_back(a,b,c,res);
return res;
}
vector<tuple<ll,ll,ll,ll> > lightestOps;
ll lightest(ll a,ll b,ll c){
if(a==b||b==c||c==a) return -1;
ll res = getLightest(a+1,b+1,c+1)-1;
//lightestOps.emplace_back(a,b,c,res);
return res;
}
void init(int T) {
}
void orderCoins() {
int c[6] = {0,1,2,3,4,5};
//A
swap(*find(c,c+6,lightest(c[0],c[1],c[2])),c[0]);
swap(*find(c,c+6,lightest(c[3],c[4],c[5])),c[1]);
swap(*find(c,c+6,lightest(c[0],c[1],c[2])),c[0]);
//B
swap(*find(c,c+6,lightest(c[1],c[2],c[3])),c[1]);
swap(*find(c,c+6,lightest(c[1],c[4],c[5])),c[1]);
//C
swap(*find(c,c+6,lightest(c[2],c[3],c[4])),c[2]);
swap(*find(c,c+6,lightest(c[2],c[4],c[5])),c[2]);
//D
swap(*find(c,c+6,lightest(c[3],c[4],c[5])),c[3]);
//E/F
swap(*find(c,c+6,heaviest(c[3],c[4],c[5])),c[5]);
rep(i,0,6) {
c[i]++;
//cout<<c[i]<<" ";
}
// cout<<endl;
answer(c);
/*rep(j,0,3){
rep(i,0,4){
ll res = getLightest(coins[i],coins[i+1],coins[i+2]);
if(res==coins[i+1]) swap(coins[i],coins[i+1]);
if(res==coins[i+2]) swap(coins[i],coins[i+2]);
}
}
if(getHeaviest(coins[3],coins[4],coins[5])==coins[4]) swap(coins[4],coins[5]);
//rep(i,0,6) cout<<coins[i]<<" ";
//cout<<endl;
answer(coins);
return;
/*heaviestOps.clear();
lightestOps.clear();
rep(i,0,100){
heaviest(rand()%6,rand()%6,rand()%6);
}
rep(i,0,100){
lightest(rand()%6,rand()%6,rand()%6);
}
vi W = {0,1,2,3,4,5};
do{
bool fail = false;
rep(i,0,heaviestOps.size()){
ll a,b,c,res;
tie(a,b,c,res) = heaviestOps[i];
if(max(W[a],max(W[b],W[c]))!=W[res])
fail = true;
}
rep(i,0,lightestOps.size()){
ll a,b,c,res;
tie(a,b,c,res) = lightestOps[i];
if(min(W[a],min(W[b],W[c]))!=W[res])
fail = true;
}
if(!fail) {
int ans[6];
rep(i,0,6) ans[W[i]] = i+1;
answer(ans);
return;
}
} while(next_permutation(all(W)));*/
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |