# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1038972 | c2zi6 | Scales (IOI15_scales) | C++14 | 1 ms | 436 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.
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define replr(i, a, b) for (int i = int(a); i <= int(b); ++i)
#define reprl(i, a, b) for (int i = int(a); i >= int(b); --i)
#define rep(i, n) for (int i = 0; i < int(n); ++i)
#define mkp(a, b) make_pair(a, b)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VPI;
typedef vector<VI> VVI;
typedef vector<VVI> VVVI;
typedef vector<VPI> VVPI;
typedef pair<ll, ll> PLL;
typedef vector<ll> VL;
typedef vector<PLL> VPL;
typedef vector<VL> VVL;
typedef vector<VVL> VVVL;
typedef vector<VPL> VVPL;
template<class T> T setmax(T& a, T b) {if (a < b) return a = b; return a;}
template<class T> T setmin(T& a, T b) {if (a < b) return a; return a = b;}
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<typename T>
using indset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#include "scales.h"
void init(int T) {
}
void answer(VI ans);
void orderCoins() {
VI ans;
if (true) {
/*getting first two elements, 4 queries*/
int ca = getLightest(1, 2, 3);
int cb = getLightest(4, 5, 6);
ans.pb(getLightest(ca, cb, (ca == 1 ? 2 : 1)));
if (ans[0] == ca) {
VI tmp;
if (1 != ca) tmp.pb(1);
if (2 != ca) tmp.pb(2);
if (3 != ca) tmp.pb(3);
ans.pb(getLightest(cb, tmp[0], tmp[1]));
} else {
VI tmp;
if (4 != cb) tmp.pb(4);
if (5 != cb) tmp.pb(5);
if (6 != cb) tmp.pb(6);
ans.pb(getLightest(ca, tmp[0], tmp[1]));
}
}
if (true) {
/*getting third element, 2 queries*/
VI rest;
replr(i, 1, 6) if (i != ans[0] && i != ans[1]) rest.pb(i);
int ca = getNextLightest(rest[0], rest[1], rest[2], ans[1]);
int cb = rest[3];
ans.pb(getLightest(ca, cb, (ca == rest[0] ? rest[1] : rest[0])));
}
rep(i, 3) {
/*getting remainging 3 elements, 3 queries*/
VI ret;
replr(i, 1, 6) {
for (int x : ans) if (i == x) goto dontadd;
ret.pb(i);
dontadd:;
}
if (ret.size() == 1) {
ans.pb(ret[0]);
continue;
}
int j = 0;
while (ret.size() < 3) ret.pb(ans[j++]);
ans.pb(getNextLightest(ret[0], ret[1], ret[2], ans.back()));
}
answer(ans);
}
void answer(VI ans) {
int w[6];
rep(i, 6) w[i] = ans[i];
answer(w);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |