# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
436574 | jeqcho | Scales (IOI15_scales) | C++17 | 5 ms | 204 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;
typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpi;
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)
#define pb push_back
#define rsz resize
#define sz(x) int(x.size())
#define all(x) begin(x), end(x)
#define fi first
#define se second
void init(int T) {
/* ... */
}
vi so(vi o)
{
int h=getHeaviest(o[0],o[1],o[2]);
int l=getLightest(o[0],o[1],o[2]);
int m;
F0R(i,3)if(o[i]!=h&&o[i]!=l)m=o[i];
return {l,m,h};
}
void orderCoins() {
vi s1 = so({1,2,3});
vi s2 = so({4,5,6});
vi ans;
while(!s1.empty()&&!s2.empty())
{
int u1=s1.back();
int u2=s2.back();
int mn;
if(u1==s1.front())mn=s2.front();
else mn=s1.front();
if(mn==u2)
{
int l=getLightest(u1,u2,ans.back());
if(l==u1)
{
s2.pop_back();
ans.pb(u2);
}
else
{
s1.pop_back();
ans.pb(u1);
}
}
else
{
int h=getHeaviest(u1,u2,mn);
if(h!=u1)s2.pop_back();
else s1.pop_back();
ans.pb(h);
}
}
reverse(all(s1));
reverse(all(s2));
ans.insert(ans.end(),all(s1));
ans.insert(ans.end(),all(s2));
reverse(all(ans));
int W[6];
F0R(i,6)W[i]=ans[i];
answer(W);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |