# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1075820 | TB_ | Scales (IOI15_scales) | C++17 | 1 ms | 440 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 <bits/stdc++.h>
#include "scales.h"
using namespace std;
#define ll long long
#define fo(i, n) for(ll i = 0; i<(n); i++)
#define F first
#define S second
#define pb push_back
#define deb(x) cout << #x << " = " << (x) << endl
#define deb2(x, y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
typedef vector<ll> vl;
typedef vector<vl> vvl;
// int getLightest(int a, int b, int c){
// cout << "light\n";
// cout << a << " " << b << " " << c << endl;
// ll res;
// cin >> res;
// return res;
// }
// int getMedian(int a, int b, int c){
// cout << "Median\n";
// cout << a << " " << b << " " << c << endl;
// ll res;
// cin >> res;
// return res;
// }
void init(int T) {
}
void orderCoins() {
int W[] = {-1, -1, -1, -1, -1, -1};
vl order = {1, 2, 3, 4, 5, 6};
fo(i, 20) swap(order[rand()%6], order[rand()%6]);
int t1 = getLightest(order[1], order[2], order[3]);
int t2 = getLightest(order[4], order[5], order[0]);
vector<int> a1, a2;
fo(i, 6){
if(t1!=i+1 && (i+1 == order[1]||i+1 == order[2]||i+1 == order[3]))a1.pb(i+1);
if(t2!=i+1 && (i+1 == order[0]||i+1 == order[5]||i+1 == order[4]))a2.pb(i+1);
}
int dist = 1;
while(dist==t1||dist==t2)dist++;
W[0] = getLightest(t1, t2, dist);
if(t1==W[0]){
W[1] = getLightest(t2, a1[0], a1[1]);
}else{
W[1] = getLightest(t1, a2[0], a2[1]);
}
vector<int> left;
fo(i, 6){
if(i+1==W[0] || i+1 == W[1]) continue;
left.pb(i+1);
}
int res = getLightest(left[0], left[1], left[2]);
int other = left[0];
if(other == res) other = left[1];
int res2 = getMedian(res, other, left[3]);
if(res2 == res){
W[2] = left[3];
W[3] = res;
W[4] = getMedian(left[0], left[1], left[2]);
fo(i, 6){
if(i+1==W[0] || i+1==W[1] || i+1==W[2] || i+1 == W[3]|| i+1 == W[4]) continue;
W[5] = i+1;
}
}else{
W[2] = res;
left.clear();
if(other == res2) other = left[3];
ll other2 = 0;
fo(i, 6){
if(i+1==W[0] || i+1 == W[1] || i+1 == W[2] || i+1 == res2 || i+1 == other) continue;
other2 = i+1;
}
res = getMedian(res2, other, other2);
if(res == res2){
W[3] = other2;
W[4] = res2;
W[5] = other;
}else if(res == other){
W[3] = res2;
W[4] = other;
W[5] = other2;
}else{
W[3] = res2;
W[4] = other2;
W[5] = other;
}
}
// fo(i, 6) deb(W[i]);
answer(W);
}
// int main(){
// orderCoins();
// return 0;
// }
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |