제출 #1367090

#제출 시각아이디문제언어결과실행 시간메모리
1367090eyadooz저울 (IOI15_scales)C++20
45.45 / 100
3 ms360 KiB
#include "scales.h"
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(x) (int) (x).size()
#define endl '\n'


void init(int T) {
    /* ... */
}
// int getHeaviest(int a, int b, int c){
//     cout << "H: " << a << " " << b << "  "<< c << endl << flush;
//     int x;
//     cin >> x;
//     return x;
// }
// int getMedian(int a, int b, int c){
//     cout << "M: " << a << " " << b << "  "<< c << endl << flush;
//     int x;
//     cin >> x;
//     return x;
// }
// int getLightest(int a, int b, int c){
//     cout << "L: " << a << " " << b << "  "<< c << endl << flush;
//     int x;
//     cin >> x;
//     return x;
// }
// void answer(int w[]){
//     for(int i = 0;i<6;i++) cout << w[i] << " ";
//         return ;
// }
void orderCoins() {
    vector<int> v;
    for(int i = 1;i <= 6;i++) v.pb(i);
    random_device rd;
    mt19937 g(rd());
    int x=rand()%19492; 
    while(x--) shuffle(all(v), g);

    vector<int> a, b;
    a.pb(getLightest(v[0],v[1],v[2]));  
    a.pb(getMedian(v[0],v[1],v[2]));  
    if(find(all(a), v[0])==a.end()) a.pb(v[0]);
    if(find(all(a), v[1])==a.end()) a.pb(v[1]);
    if(find(all(a), v[2])==a.end()) a.pb(v[2]);
    b.pb(getLightest(v[3],v[4],v[5]));  
    b.pb(getMedian(v[3],v[4],v[5]));  
    if(find(all(b), v[3])==b.end()) b.pb(v[3]);
    if(find(all(b), v[4])==b.end()) b.pb(v[4]);
    if(find(all(b), v[5])==b.end()) b.pb(v[5]);
    
    vector<int> s;
    while(min(sz(a), sz(b))>=1&&sz(a)+sz(b)>=3) {
        if(sz(a)<sz(b)) swap(a, b);
        auto it=getLightest(a[0], a[1], b[0]);
        s.pb(it);
        if(find(all(a), it)!=a.end()) a.erase(find(all(a), it));
        if(find(all(b), it)!=b.end()) b.erase(find(all(b), it));
    }
    if(sz(a)&&sz(b)) {
        auto it=getMedian(a[0], b[0], s.back());
        s.pb(it);
        if(find(all(a), it)!=a.end()) a.erase(find(all(a), it));
        if(find(all(b), it)!=b.end()) b.erase(find(all(b), it));    
    }
    reverse(all(a));
    reverse(all(b));
    while(sz(a)) s.pb(a.back()), a.pop_back();
    while(sz(b)) s.pb(b.back()), b.pop_back();
    int w[6];
    for(int i = 0;i < 6;i++) w[i]=s[i];
    answer(w);
}
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…