# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
411918 | losmi247 | Scales (IOI15_scales) | C++14 | 2 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 long ll;
const int N = 7;
/*int *p;
int gde[N];
void answer(int *sta){
for(int i = 0; i < 6; i++){
if(sta[i] != p[i]){
cout << "WA" << endl;
exit(0);
}
}
cout << "OK" << endl;
}
int getHeaviest(int a,int b,int c){
vector <int> v = {gde[a],gde[b],gde[c]};
sort(v.begin(),v.end());
return p[v[2]];
}
int getLightest(int a,int b,int c){
vector <int> v = {gde[a],gde[b],gde[c]};
sort(v.begin(),v.end());
return p[v[0]];
}
int getMedian(int a,int b,int c){
vector <int> v = {gde[a],gde[b],gde[c]};
sort(v.begin(),v.end());
return p[v[1]];
}
int getNextLightest(int a,int b,int c,int d){
if(gde[a] < gde[d] && gde[b] < gde[d] && gde[c] < gde[d]) return getLightest(a,b,c);
vector <int> v;
if(gde[a] > gde[d]) v.push_back(gde[a]);
if(gde[b] > gde[d]) v.push_back(gde[b]);
if(gde[c] > gde[d]) v.push_back(gde[c]);
sort(v.begin(),v.end());
return p[v[0]];
}*/
int t;
int n = 6;
void init(int T){
t = T;
}
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
vector <int> jedanpojedan(){
vector <int> v;
for(int i = 1; i <= n; i++) v.push_back(i);
shuffle(v.begin(),v.end(),rnd);
vector <int> odg;
while(v.size() > 3){
vector <int> red;
for(int i = 0; i < v.size(); i++) red.push_back(i);
//shuffle(red.begin(),red.end(),rnd);
for(int h = 0; h < red.size(); h++){
int i = red[h];
int ovaj = v[i];
int drugi = -1,pos = 0;
for(int j = 0; j < v.size(); j++){
if(j == i) continue;
drugi = v[j];
pos = j;
}
bool jestenajmanji = 1;
for(int j = 0; j < v.size(); j++){
if(j == i || j == pos) continue;
int daj = getLightest(v[i],drugi,v[j]);
if(daj != v[i]){
jestenajmanji = 0;
break;
}
}
if(jestenajmanji){
odg.push_back(v[i]);
vector <int> cuv;
while(v.back() != v[i]){
cuv.push_back(v.back());
v.pop_back();
}
v.pop_back();
reverse(cuv.begin(),cuv.end());
for(auto f : cuv){
v.push_back(f);
}
break;
}
}
}
int najm = getLightest(v[0],v[1],v[2]), sred = getMedian(v[0],v[1],v[2]), najv = getHeaviest(v[0],v[1],v[2]);
odg.push_back(najm);
odg.push_back(sred);
odg.push_back(najv);
return odg;
}
vector <int> nestodrugo(){
int s1 = getLightest(1,2,3);
}
void orderCoins(){
vector <int> v = jedanpojedan();
int *ans = (int*)malloc(sizeof(int)*6);
for(int i = 0; i < 6; i++) ans[i] = v[i];
answer(ans);
}
/*int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
int tc;
cin >> tc;
init(tc);
for(int i = 1; i <= tc; i++){
p = (int*)malloc(sizeof(int)*6);
for(int j = 0; j < 6; j++){ cin >> p[j]; gde[p[j]] = j; }
orderCoins();
}
}*/
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |