Submission #158456

#TimeUsernameProblemLanguageResultExecution timeMemory
158456davitmargScales (IOI15_scales)C++17
Compilation error
0 ms0 KiB
/*DavitMarg*/
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <stack>
#include <cassert>
#include <iterator>
#include <fstream>
#define mod 1000000000ll
#define LL long long
#define LD long double
#define MP make_pair
#define PB push_back
#define all(v) v.begin(), v.end()
using namespace std;

#ifndef death
#define "grader.h"
#endif

#ifdef death

int getHeaviest(int a, int b, int c)
{
    cout << "? Heavy" << a << " " << b << " " << c << endl;
    int res;
    cin >> res;
    return res;
}

int getMedian(int a, int b, int c)
{
    cout << "? Median" << a << " " << b << " " << c << endl;
    int res;
    cin >> res;
    return res;
}

int getLightest(int a, int b, int c)
{
    cout << "? Light" << a << " " << b << " " << c << endl;
    int res;
    cin >> res;
    return res;
}

int getNextLightest(int a, int b, int c, int d)
{
    cout << "? " << a << " " << b << " " << c << " " << d << endl;
    int res;
    cin >> res;
    return res;
}

void answer(int *a)
{
    cout << "! ";
    for (int i = 0; i < 6; i++)
        cout << a[i] << " ";
    cout << endl;
}

#endif

int n = 6;

void init(int T)
{
    srand(644645 + T);
}

void orderCoins()
{
    vector<int> ind, l, r, ans;
    for (int i = 1; i <= n; i++)
        ind.PB(i);
    random_shuffle(all(ind));

    l.PB(getLightest(ind[0], ind[1], ind[2]));
    l.PB(getMedian(ind[0], ind[1], ind[2]));
    for (int i = 0; i < 3; i++)
        if (ind[i] != l[0] && ind[i] != l[1])
            l.PB(ind[i]);

    r.PB(getLightest(ind[3], ind[4], ind[5]));
    r.PB(getMedian(ind[3], ind[4], ind[5]));
    for (int i = 3; i < n; i++)
        if (ind[i] != r[0] && ind[i] != r[1])
            r.PB(ind[i]);

    reverse(all(l));
    reverse(all(r));
    ans.PB(getLightest(r.back(), l.back(), r[r.size() - 2]));
    if (ans.back() == r.back())
        r.pop_back();
    else
        l.pop_back();

    while (!l.empty() || !r.empty())
    {
        if (l.empty())
        {
            ans.PB(r.back());
            r.pop_back();
        }
        else if (r.empty())
        {
            ans.PB(l.back());
            l.pop_back();
        }
        else
        {
            ans.PB(getMedian(r.back(), l.back(), ans[0]));
            if (ans.back() == r.back())
                r.pop_back();
            else
                l.pop_back();
        }
    }
    int ANS[6];
    for (int i = 0; i < n; i++)
        ANS[i] = ans[i];
    answer(ANS);
}

#ifdef death

int main()
{
    int T;
    cin >> T;
    init(T);
    while (T--)
    {
        orderCoins();
    }
    return 0;
}

#endif

/*

2 2 8
1 7

*/

Compilation message (stderr)

scales.cpp:26:9: error: macro names must be identifiers
 #define "grader.h"
         ^~~~~~~~~~
scales.cpp: In function 'void orderCoins()':
scales.cpp:87:10: error: 'getLightest' was not declared in this scope
     l.PB(getLightest(ind[0], ind[1], ind[2]));
          ^~~~~~~~~~~
scales.cpp:87:10: note: suggested alternative: 'gettext'
     l.PB(getLightest(ind[0], ind[1], ind[2]));
          ^~~~~~~~~~~
          gettext
scales.cpp:88:10: error: 'getMedian' was not declared in this scope
     l.PB(getMedian(ind[0], ind[1], ind[2]));
          ^~~~~~~~~
scales.cpp:88:10: note: suggested alternative: 'getdelim'
     l.PB(getMedian(ind[0], ind[1], ind[2]));
          ^~~~~~~~~
          getdelim
scales.cpp:131:5: error: 'answer' was not declared in this scope
     answer(ANS);
     ^~~~~~
scales.cpp:131:5: note: suggested alternative: 'ans'
     answer(ANS);
     ^~~~~~
     ans