# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1015501 | amine_aroua | Scales (IOI15_scales) | C++17 | 1 ms | 432 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"
//#include "graderlib.cpp"
using namespace std;
void init(int T) {
}
void sort(vector<int> &a)
{
vector<int> nw = {-1 , -1 , -1};
nw[0] = getLightest(a[0] , a[1] , a[2]);
nw[2] = getHeaviest(a[0] , a[1] , a[2]);
for(auto x : a)
{
if(std::find(nw.begin(), nw.end(),x) == nw.end())
{
nw[1] = x;
}
}
a = nw;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void orderCoins() {
/* ... */
vector<int> a ,b;
vector<int> all ;
for(int i = 1 ; i <= 6 ; i++)
all.push_back(i);
shuffle(all.begin() , all.end() , rng);
for(int i = 0 ; i < 6 ; i++)
{
if(i < 3)
a.push_back(all[i]);
else
b.push_back(all[i]);
}
// a = {3 , 6 , 5};
// b = {1 , 2 , 4};
sort(a);
sort(b);
vector<int> d = b;
int c[6];
vector<int> nxts;
for(int j = 0 ; j < 3 ; j++)
{
int nxt = getNextLightest(b[0] , b[1] , b[2] , a[j]);
nxts.push_back(nxt);
// d.insert(find(d.begin() , d.end() , nxt) , a[j]);
}
int last = -1;
for(int j = 2 ; j >= 0 ; j--)
{
if(nxts[j] != b[0])
{
last = j;
break;
}
}
if(last == -1)
{
int mid = 1;
if(getHeaviest(a[mid] , b[2] , b[1]) == a[mid])
{
if(getHeaviest(a[mid - 1] , b[2] , b[1]) == a[mid - 1])
mid = 0;
}
else
{
if(getHeaviest(a[2] , b[2] , b[1]) == a[2])
mid = 2;
else
mid = 3;
}
for(int i = 0 ; i < mid ; i++)
d.insert(find(d.begin() , d.end() , nxts[i]) , a[i]);
for(int i = mid ; i < 3 ; i++)
d.push_back(a[i]);
}
else
{
for(int i = 0 ; i <= last ; i++)
{
d.insert(find(d.begin() , d.end() , nxts[i]) , a[i]);
}
for(int i = last + 1; i < 3 ; i++)
d.push_back(a[i]);
}
for(int i = 0 ; i < 6 ; i++)
c[i] = d[i];
answer(c);
}
//int main() {
//
// int T, i;
//
// T = _getNumberOfTests();
// init(T);
// for (i = 1; i <= T; i++) {
// _initNewTest();
// orderCoins();
// }
// return 0;
//}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |