Submission #374958

# Submission time Handle Problem Language Result Execution time Memory
374958 2021-03-08T16:53:12 Z idk321 Scales (IOI15_scales) C++11
71.4286 / 100
1 ms 492 KB
#include "scales.h"

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

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

void orderCoins() {
    /* ... */


    int a = getLightest(1, 2, 3);
    int b = getLightest(4, 5, 6);
    set<int> l = {1, 2, 3};
    set<int> r = {4, 5, 6};

    l.erase(a);
    r.erase(b);
    vector<int> res;
    int c = getLightest(*l.begin(), a, b);
    res.push_back(c);
    if (c == a)
    {
        swap(a, b);
        swap(l, r);
    }
    auto it2 = r.begin();
    it2++;
    int x = getLightest(a, *r.begin(), *it2);
    int oldX = x;
    res.push_back(x);
    if (x == a)
    {
        set<int> other;
        for (int i : l) other.insert(i);
        for (int i : r) other.insert(i);
        auto it3 = other.begin();
        vector<int> v(3);
        v[0] = *it3;
        it3++;
        v[1] = *it3;
        it3++;
        v[2] = *it3;
        int x = getLightest(v[0], v[1], v[2]);
        other.erase(x);
        int y = *other.begin();
        other.erase(y);
        int z = *other.begin();
        other.erase(z);
        int d = *other.begin();

        int t1 = getNextLightest(oldX, x, y, d);
        if (t1 == x)
        {
            res.push_back(d);
            res.push_back(x);
            int t2 = getMedian(oldX, y, z);
            if (t2 == y)
            {
                res.push_back(y);
                res.push_back(z);
            } else
            {
                res.push_back(z);
                res.push_back(y);
            }
        } else
        {
            if (t1 == oldX) swap(d, y);
            res.push_back(x);
            int t2 = getMedian(y, z, d);
            if (t2 == z)
            {
                res.push_back(d);
                res.push_back(z);
                res.push_back(y);
            } else if (t2 == d)
            {
                res.push_back(z);
                res.push_back(d);
                res.push_back(y);
            } else
            {
                res.push_back(d);
                res.push_back(y);
                res.push_back(z);
            }
        }
    } else
    {
        r.erase(x);
        set<int> other;
        for (int i : l) other.insert(i);
        for (int i : r) other.insert(i);
        auto it3 = other.begin();
        vector<int> v(3);
        for (int i = 0; i < 3; i++)
        {
            v[i] = *it3;
            it3++;
        }
        int x = getLightest(v[0], v[1], v[2]);
        int y = getMedian(v[0], v[1], v[2]);
        other.erase(x);
        other.erase(y);
        int last = *other.begin();
        if (x == *r.begin())
        {
            int z = getLightest(x, a, y);
            if (z == a)
            {
                res.push_back(a);
                res.push_back(x);
                res.push_back(y);
                res.push_back(last);
            } else
            {
                res.push_back(x);
                res.push_back(a);
                res.push_back(y);
                res.push_back(last);
            }
        } else
        {
            res.push_back(a);
            res.push_back(x);
            res.push_back(y);
            res.push_back(last);
        }
    }

    int W[] = {1, 2, 3, 4, 5, 6};
    for (int i = 0; i < 6; i++) W[i] = res[i];
    answer(W);

}

/*
1
1 3 2 5 4 6
*/

Compilation message

scales.cpp: In function 'void init(int)':
scales.cpp:7:15: warning: unused parameter 'T' [-Wunused-parameter]
    7 | void init(int T) {
      |           ~~~~^
scales.cpp: In function 'void orderCoins()':
scales.cpp:47:13: warning: declaration of 'x' shadows a previous local [-Wshadow]
   47 |         int x = getLightest(v[0], v[1], v[2]);
      |             ^
scales.cpp:32:9: note: shadowed declaration is here
   32 |     int x = getLightest(a, *r.begin(), *it2);
      |         ^
scales.cpp:105:13: warning: declaration of 'x' shadows a previous local [-Wshadow]
  105 |         int x = getLightest(v[0], v[1], v[2]);
      |             ^
scales.cpp:32:9: note: shadowed declaration is here
   32 |     int x = getLightest(a, *r.begin(), *it2);
      |         ^
# Verdict Execution time Memory Grader output
1 Partially correct 1 ms 364 KB Output is partially correct
2 Partially correct 1 ms 364 KB Output is partially correct
3 Partially correct 1 ms 364 KB Output is partially correct
4 Partially correct 1 ms 364 KB Output is partially correct
5 Partially correct 1 ms 364 KB Output is partially correct
6 Partially correct 1 ms 492 KB Output is partially correct
7 Partially correct 1 ms 364 KB Output is partially correct
8 Partially correct 1 ms 364 KB Output is partially correct
9 Partially correct 1 ms 364 KB Output is partially correct
10 Partially correct 1 ms 364 KB Output is partially correct
11 Partially correct 1 ms 364 KB Output is partially correct
12 Partially correct 1 ms 364 KB Output is partially correct
13 Partially correct 1 ms 364 KB Output is partially correct
14 Partially correct 1 ms 364 KB Output is partially correct
15 Partially correct 1 ms 364 KB Output is partially correct
16 Partially correct 1 ms 364 KB Output is partially correct
17 Partially correct 1 ms 364 KB Output is partially correct
18 Partially correct 1 ms 364 KB Output is partially correct
19 Partially correct 1 ms 364 KB Output is partially correct
20 Partially correct 1 ms 364 KB Output is partially correct
21 Partially correct 1 ms 364 KB Output is partially correct
22 Partially correct 1 ms 364 KB Output is partially correct
23 Partially correct 0 ms 256 KB Output is partially correct
24 Partially correct 1 ms 364 KB Output is partially correct
25 Partially correct 1 ms 364 KB Output is partially correct
26 Partially correct 1 ms 364 KB Output is partially correct
27 Partially correct 1 ms 364 KB Output is partially correct
28 Partially correct 1 ms 364 KB Output is partially correct
29 Partially correct 1 ms 364 KB Output is partially correct
30 Partially correct 1 ms 364 KB Output is partially correct
31 Partially correct 1 ms 364 KB Output is partially correct
32 Partially correct 1 ms 364 KB Output is partially correct
33 Partially correct 1 ms 364 KB Output is partially correct
34 Partially correct 1 ms 364 KB Output is partially correct
35 Partially correct 1 ms 364 KB Output is partially correct
36 Partially correct 1 ms 364 KB Output is partially correct
37 Partially correct 1 ms 364 KB Output is partially correct
38 Partially correct 1 ms 364 KB Output is partially correct
39 Partially correct 1 ms 364 KB Output is partially correct
40 Partially correct 1 ms 364 KB Output is partially correct