제출 #788856

#제출 시각아이디문제언어결과실행 시간메모리
788856fatemetmhr저울 (IOI15_scales)C++17
컴파일 에러
0 ms0 KiB
//  ~ Be Name Khoda ~  //
 
#include "scales.h"
#include <bits/stdc++.h>
//#pragma GCC optimize ("O3")
//#pragma GCC target("avx2")
//#pragma GCC optimize("unroll-loops,Ofast")
 
using namespace std;
 
typedef long long ll;
 
#define pb       push_back
#define mp       make_pair
#define all(x)   x.begin(), x.end()
#define fi       first
#define se       second
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
 
const int maxn  =  1e6   + 10;
const int maxn5 =  5e5   + 10;
const int maxnt =  1.2e6 + 10;
const int maxn3 =  1e3   + 10;
const int mod   =  1e9   + 7;
const ll  inf   =  1e18;
 
/*
0 -> getLightest()
1 -> getMedian()
2 -> getHeaviest()
getNextLightest();
*/

struct Comp{
    int x[3], cnt[3][3];

    int find_order(int a){
        if(a == x[0])
            return 0;
        if(a == x[1])
            return 1;
        if(a == x[2])
            return 2;
        return -1;
    }

} op1[70];



struct BS{
    int x[3], y[3], cnt[3][3];

    int find_order(int a){
        if(a == x[0])
            return 0;
        if(a == x[1])
            return 1;
        if(a == x[2])
            return 2;
        return -1;
    }

} op2[70];

int pt1 = 0, pt2 = 0;

struct perm{
    int a[6];

    int get_op1(int ty, Comp c){
        int cnt = 0;
        for(int i = 0; i < 6; i++){
            if(c.find_order(a[i]) != -1)
                cnt++;
            if(cnt - 1 == ty)
                return c.find_order(a[i]);
        }
        return -1;
    }

    int get_op2(int ty, BS c){
        for(int i = 0; i < 6; i++) if(a[i] == c.y[ty]){
            for(int j = (i + 1) % 6; ; j = (j + 1) % 6)
                if(c.find_order(a[j]) != -1)
                    return c.find_order(a[j]);
        }
        return -1;
    }    

} av[1000];

bool rem[1000];
 
vector <pair<int, pair<int, int>>> good;
set <pair<int, pair<int, int>>> bad;


void init(int T) {
    bad.insert({0, {19, 0}});
    bad.insert({0, {10, 2}});
    bad.insert({0, {4, 2}});
    bad.insert({0, {1, 2}});
    int a[6];
    for(int i = 0; i < 6; i++)
        a[i] = i + 1;
    for(int i = 0; i < 720; i++){
        for(int j = 0; j < 6; j++)
            av[i].a[j] = a[j];
        next_permutation(a, a + 6);
    }
    for(int i = 1; i <= 6; i++)
        for(int j = i + 1; j <= 6; j++)
            for(int k = j + 1; k <= 6; k++){
                op1[pt1].x[0] = i;
                op1[pt1].x[1] = j;
                op1[pt1].x[2] = k;
                pt1++;
                op2[pt2].x[0] = i;
                op2[pt2].x[1] = j;
                op2[pt2].x[2] = k;
                int ind = 0;
                for(int x = 1; x <= 6; x++) if(x != i && x != j && x != k)
                    op2[pt2].y[ind++] = x;
                pt2++;
            }
}

int lim[] = {240, 80, 27, 9, 3, 1, 0, 0, 0};
 
bool orderCoins() {
    int ret[6];

    pair <int, pair<int, int>> last;

    memset(rem, false, sizeof rem);
    int have = 720;
    int ptlim = 0;
    while(have > 1){
        good.clear();
        pair <int, pair<int, int>> mnid = {0, {0, 0}};
        vector <int> mn = {730, 730, 730};
        vector <int> tmp = mn;
        for(int i = 0; i < pt1; i++){
            memset(op1[i].cnt, 0, sizeof op1[i].cnt);
            for(int j = 0; j < 720; j++) if(!rem[j]){
                op1[i].cnt[0][av[j].get_op1(0, op1[i])]++;
                op1[i].cnt[1][av[j].get_op1(1, op1[i])]++;
                op1[i].cnt[2][av[j].get_op1(2, op1[i])]++;
            }
            for(int j = 0; j < 3; j++){
                sort(op1[i].cnt[j], op1[i].cnt[j] + 3);
                tmp[0] = op1[i].cnt[j][2];
                tmp[1] = op1[i].cnt[j][1];
                tmp[2] = op1[i].cnt[j][0];
                //cout << "he? " << i << ' ' << j << ' ' << mn << ' ' << val << endl;
                if(tmp < mn && bad.find({0, {i, j}}) == bad.end()){
                    mn = tmp;
                    mnid = {0, {i, j}};
                }
                if(tmp[0] <= lim[ptlim])
                    good.pb(mnid);
            }
        }
        for(int i = 0; i < pt2; i++){
            memset(op2[i].cnt, 0, sizeof op2[i].cnt);
            for(int j = 0; j < 720; j++) if(!rem[j]){
                op2[i].cnt[0][av[j].get_op2(0, op2[i])]++;
                op2[i].cnt[1][av[j].get_op2(1, op2[i])]++;
                op2[i].cnt[2][av[j].get_op2(2, op2[i])]++;
            }
            for(int j = 0; j < 3; j++){
                sort(op2[i].cnt[j], op2[i].cnt[j] + 3);
                tmp[0] = op2[i].cnt[j][2];
                tmp[1] = op2[i].cnt[j][1];
                tmp[2] = op2[i].cnt[j][0];
                //cout << "he? " << i << ' ' << j << ' ' << mn << ' ' << val << endl;
                if(tmp < mn && bad.find({1, {i, j}}) == bad.end()){
                    mn = tmp;
                    mnid = {1, {i, j}};
                }
                if(tmp[0] <= lim[ptlim])
                    good.pb(mnid);
            }
        }

        /*
        if(good.size())
            mnid = good[rng() % (int(good.size()))];
        cout << good.size() << endl;
        */
        int ans;
        if(mnid.fi == 0){
            int x;
            if(mnid.se.se == 0)
                x = getLightest(op1[mnid.se.fi].x[0], op1[mnid.se.fi].x[1], op1[mnid.se.fi].x[2]);
            if(mnid.se.se == 1)
                x = getMedian(op1[mnid.se.fi].x[0], op1[mnid.se.fi].x[1], op1[mnid.se.fi].x[2]);
            if(mnid.se.se == 2)
                x = getHeaviest(op1[mnid.se.fi].x[0], op1[mnid.se.fi].x[1], op1[mnid.se.fi].x[2]);
            ans = op1[mnid.se.fi].find_order(x);
            for(int i = 0; i < 720; i++) 
                if(!rem[i] && av[i].get_op1(mnid.se.se, op1[mnid.se.fi]) != ans){
                    rem[i] = true;
                    have--;
                }
            /*
            cout << "found out op1 " << ' ' << mnid.fi << ' ' << mnid.se.fi << ' ' << mnid.se.se << endl;
            for(int i = 0; i < 3; i++)
                cout << op1[mnid.se.fi].x[i] << ' ';
            cout << endl;
            cout << av[0].get_op1(2, op1[0]) << endl;
            cout << op1[0].cnt[0][0] << ' ' << op1[0].cnt[0][1] << ' ' << op1[0].cnt[0][2] << endl;
            //*/

        }
        else{
            int x = getNextLightest(op2[mnid.se.fi].x[0], op2[mnid.se.fi].x[1], op2[mnid.se.fi].x[2], op2[mnid.se.fi].y[mnid.se.se]);
            ans = op2[mnid.se.fi].find_order(x);
            for(int i = 0; i < 720; i++) 
                if(!rem[i] && av[i].get_op2(mnid.se.se, op2[mnid.se.fi]) != ans){
                    rem[i] = true;
                    have--;
                }
            /*
            cout << "found out op2 " << ' ' << mnid.fi << ' ' << mnid.se.fi << ' ' << mnid.se.se << endl;
            for(int i = 0; i < 3; i++)
                cout << op2[mnid.se.fi].x[i] << ' ';
            cout << op2[mnid.se.fi].y[mnid.se.se] << endl;
            //*/
        }
        //cout << "ya " << have << endl;
        if(have > lim[ptlim]){
            mnid = last;
            cout << "bad.insert({" << mnid.fi << ", {" << mnid.se.fi << ", " << mnid.se.se << "}});\n";
            bad.insert(mnid);
            return false;
        }
        last = mnid;
        ptlim++;
    }
    for(int i = 0; i < 720; i++) if(!rem[i])
        for(int j = 0; j < 6; j++)
            ret[j] = av[i].a[j];
    answer(ret);
    return true;
}

컴파일 시 표준 에러 (stderr) 메시지

scales.cpp: In function 'void init(int)':
scales.cpp:101:15: warning: unused parameter 'T' [-Wunused-parameter]
  101 | void init(int T) {
      |           ~~~~^
scales.cpp: At global scope:
scales.cpp:133:6: error: ambiguating new declaration of 'bool orderCoins()'
  133 | bool orderCoins() {
      |      ^~~~~~~~~~
In file included from scales.cpp:3:
scales.h:9:6: note: old declaration 'void orderCoins()'
    9 | void orderCoins();
      |      ^~~~~~~~~~