# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
249339 | ryansee | Scales (IOI15_scales) | C++14 | 1 ms | 384 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 FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define eb emplace_back
#define ins insert
#define f first
#define s second
#define cbr cerr<<"hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ll(x.size())
#define all(x) (x).begin(), (x).end()
#define lbd(x,y) (lower_bound(all(x),y)-x.begin())
#define ubd(x,y) (upper_bound(all(x),y)-x.begin())
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); //can be used by calling rng() or shuffle(A, A+n, rng)
inline long long rand(long long x, long long y) { return rng() % (y+1-x) + x; } //inclusivesss
string inline to_string(char c) {string s(1,c);return s;} template<typename T> inline T gcd(T a,T b){ return a==0?llabs(b):gcd(b%a,a); }
using ll=long long;
using ld=long double;
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
using pi=pair<ll,ll>; using spi=pair<ll,pi>; using dpi=pair<pi,pi>;
#define LLINF ((long long)1e18)
#define INF int(1e9+1e6)
#define MAXN (300006)
void init(int T) {
/* ... */
}
void orderCoins() {
int a[3], b[3];
b[0] = getLightest(4,5,6);
b[1] = getMedian(4,5,6);
FOR(i,4,6)if(b[0]!=i&&b[1]!=i)b[2]=i;
a[2] = getHeaviest(1,2,3);
vector<int> notin = {}, v;
FOR(i,1,3)if(i^a[2])notin.eb(i);
int num = getLightest(notin[0], notin[1], b[0]);
if(num == b[0]){
v.eb(b[0]);
num = getLightest(notin[0], notin[1], b[1]);
if(num == b[1]) {
v.eb(b[1]);
num = getLightest(notin[0], notin[1], b[2]);
if(num == b[2]){
v.eb(b[2]);
num = getLightest(a[2],notin[0],notin[1]);
a[0]=num;
FOR(i,1,3)if(a[0]!=i&&a[2]!=i)a[1]=i;
v.eb(a[0]), v.eb(a[1]), v.eb(a[2]);
assert(siz(v)==6);
}else{
a[0]=num;
FOR(i,1,3)if(a[0]!=i&&a[2]!=i)a[1]=i;
v.eb(a[0]),v.eb(a[1]),v.eb(a[2]);
FOR(i,2,2){
num = getNextLightest(1,2,3,b[i]);
if(num==a[0]){
v.eb(b[i]);
}else{
ll pos=find(all(v),num)-v.begin();
v.insert(v.begin()+pos, b[i]);
}
}
assert(siz(v)==6);
}
}else{
a[0]=num;
FOR(i,1,3)if(a[0]!=i&&a[2]!=i)a[1]=i;
v.eb(a[0]),v.eb(a[1]),v.eb(a[2]);
FOR(i,1,2){
num = getNextLightest(1,2,3,b[i]);
if(num==a[0]){
v.eb(b[i]);
}else{
ll pos=find(all(v),num)-v.begin();
v.insert(v.begin()+pos, b[i]);
}
}
assert(siz(v)==6);
}
}else{
a[0]=num;
FOR(i,1,3)if(a[0]!=i&&a[2]!=i)a[1]=i;
v = {a[0],a[1],a[2]};
FOR(i,0,2){
num = getNextLightest(1,2,3,b[i]);
if(num==a[0]){
v.eb(b[i]);
}else{
ll pos=find(all(v),num)-v.begin();
v.insert(v.begin()+pos, b[i]);
}
}
assert(siz(v)==6);
}
int W[6];
FOR(i,0,5)W[i]=v[i];
answer(W);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |