제출 #1273616

#제출 시각아이디문제언어결과실행 시간메모리
1273616AvianshScales (IOI15_scales)C++17
0 / 100
11 ms420 KiB
#include "scales.h"
#include <bits/stdc++.h>

using namespace std;

void init(int T) {
    /* ... */
}

const int mx = 6;

bool check(vector<set<int>>g, int perm[]){
    for(int i = 1;i<mx;i++){
        if(g[perm[i-1]].find(perm[i])==g[perm[i-1]].end()){
            return 0;
        }
    }
    return 1;
}
bool done(vector<set<int>>g){
    //check for path of length mx
    int perm[mx];
    iota(perm,perm+mx,0);

    if(check(g,perm)){
        return 1;
    }

    while(next_permutation(perm,perm+mx)){
        if(check(g,perm)){
            return 1;
        }
    }
    return 0;
}
void orderCoins() {
    vector<set<int>>g(6,set<int>());
    while(!done(g)){
        int a = rand()%6;
        int b = rand()%6;
        int c = rand()%6;
        if(a==b||b==c||c==a){
            continue;
        }
        a++;b++;c++;
        if(rand()%2){
            int mx = getHeaviest(a,b,c);
            mx--;a--;b--;c--;
            g[a].insert(mx);
            g[b].insert(mx);
            g[c].insert(mx);
            g[mx].erase(mx);
        }
        else{
            int mn = getLightest(a,b,c);
            mn--;a--;b--;c--;
            g[mn].insert(a);
            g[mn].insert(b);
            g[mn].insert(c);
            g[mn].erase(mn);
        }
    }
    //done
    int perm[mx];
    iota(perm,perm+mx,0);

    if(check(g,perm)){
        for(int i : perm){
            i++;
        }
        answer(perm);
        return;
    }

    while(next_permutation(perm,perm+mx)){
        if(check(g,perm)){
            for(int i : perm){
                i++;
            }
            answer(perm);
            return;
        }
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...