Submission #1038970

#TimeUsernameProblemLanguageResultExecution timeMemory
1038970c2zi6Scales (IOI15_scales)C++14
Compilation error
0 ms0 KiB
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define replr(i, a, b) for (int i = int(a); i <= int(b); ++i)
#define reprl(i, a, b) for (int i = int(a); i >= int(b); --i)
#define rep(i, n) for (int i = 0; i < int(n); ++i)
#define mkp(a, b) make_pair(a, b)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VPI;
typedef vector<VI> VVI;
typedef vector<VVI> VVVI;
typedef vector<VPI> VVPI;
typedef pair<ll, ll> PLL;
typedef vector<ll> VL;
typedef vector<PLL> VPL;
typedef vector<VL> VVL;
typedef vector<VVL> VVVL;
typedef vector<VPL> VVPL;
template<class T> T setmax(T& a, T b) {if (a < b) return a = b; return a;}
template<class T> T setmin(T& a, T b) {if (a < b) return a; return a = b;}
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<typename T>
using indset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#include "scales.h"

void init(int T) {
}

void answer(VI ans);
void orderCoins() {
    VI ans;

    if (true) {
        /*getting first two elements, 4 queries*/
        int ca = getLightest(1, 2, 3);
        int cb = getLightest(4, 5, 6);
        ans.pb(getLightest(ca, cb, (ca == 1 ? 2 : 1)));
        if (ans[0] == ca) {
            VI tmp;
            if (1 != ca) tmp.pb(1);
            if (2 != ca) tmp.pb(2);
            if (3 != ca) tmp.pb(3);
            ans.pb(getLightest(cb, tmp[0], tmp[1]));
        } else {
            VI tmp;
            if (4 != cb) tmp.pb(4);
            if (5 != cb) tmp.pb(5);
            if (6 != cb) tmp.pb(6);
            ans.pb(getLightest(ca, tmp[0], tmp[1]));
        }
    }
    if (true) {
        /*getting third element, 2 queries*/
        VI rest;
        replr(i, 1, 6) if (i != ans[0] && i != ans[1]) rest.pb(i);
        int ca = getNextLightest(rest[0], rest[1], rest[2], ans[1]);
        int cb = rest[3];
        ans.pb(getLightest(ca, cb, (ca == rest[0] ? rest[1] : rest[0])));
    }
    rep(i, 3) {
        /*getting remainging 3 elements, 3 queries*/
        VI ret;
        replr(i, 1, 6) {
            for (int x : ans) if (i == x) goto dontadd;
            ret.pb(i);
            dontadd:;
        }
        if (ret.size() == 1) {
            ans.pb(ret[0]);
            continue;
        }
        int j = 0;
        while (ret.size() < 3) ret.pb(ans[j++]);
        ans.pb(getNextLightest(ret[0], ret[1], ret[2], ans.back()));
    }

    answer(ans);
}





Compilation message (stderr)

scales.cpp: In function 'void init(int)':
scales.cpp:34:15: warning: unused parameter 'T' [-Wunused-parameter]
   34 | void init(int T) {
      |           ~~~~^
scales.cpp: In function 'void orderCoins()':
scales.cpp:71:15: warning: declaration of 'i' shadows a previous local [-Wshadow]
   71 |         replr(i, 1, 6) {
      |               ^
scales.cpp:7:33: note: in definition of macro 'replr'
    7 | #define replr(i, a, b) for (int i = int(a); i <= int(b); ++i)
      |                                 ^
scales.cpp:68:9: note: shadowed declaration is here
   68 |     rep(i, 3) {
      |         ^
scales.cpp:9:28: note: in definition of macro 'rep'
    9 | #define rep(i, n) for (int i = 0; i < int(n); ++i)
      |                            ^
/usr/bin/ld: /tmp/cc601Kfm.o: in function `orderCoins':
scales.cpp:(.text+0x461): undefined reference to `answer(std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status