답안 #286488

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
286488 2020-08-30T13:13:52 Z Puddlestomps 저울 (IOI15_scales) C++17
45.4545 / 100
1 ms 256 KB
#include "bits/stdc++.h"

#define TESTING 0
#if TESTING
#include "graderlib.c"
#else
#include "scales.h"
#endif

using namespace std;

/*
bool lessThan(int a, int b, int val, bool lower = false)
{
    if(lower) //val is lower than a and b
    {
        int k = getMedian(a, b, val);
        if(k == a) return true;
        else return false;
    }
    else
    {
        int k = getLightest(a, b, val);
        if(k == a) return true;
        else return false;
    }
}

void swap(int* a, int* b)
{
    if(a == b) return;
    *a = (*a) ^ (*b);
    *b = (*a) ^ (*b);
    *a = (*a) ^ (*b);
}

void sort(int* begin, int* end, int mid = -1, bool less = false)
{
    if(end - begin == 1) return;
    if(end - begin == 2)
    {
        if(lessThan(*begin, *(end - 1), mid, less)) swap(begin, end - 1);
        return;
    }

    int first = *begin, second = *(begin + 1), third = *(begin + 2);
    int mid = getMedian(first, second, third);

    int* m = nullptr;
    if(mid == first) m = begin;
    else if(mid == second) m = begin + 1;
    else m = begin + 2;

    int* back = end - 1;
    swap(m, back);
    --back;
    int* front = begin;

    while(front != back)
    {
        if(*front)
    }

}*/


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

void orderCoins()
{
    set<int> unsorted = {1, 2, 3, 4, 5, 6};
    int W[] = {1, 2, 3, 4, 5, 6};
    sort(W, W + 6);

    int l1 = getLightest(1, 2, 3);
    int l2 = getLightest(6, 4, 5);
    int other = 1;
    if(other == l1 || other == l2) other++;
    if(other == l1 || other == l2) other++;
    int l = getLightest(other, l1, l2);
    unsorted.erase(l);
    //int lind = l - 1;
    W[0] = l;
    //First coin is now sorted
    if(TESTING) cerr << "W[0] = " << l << "\n";

    auto it = unsorted.begin();
    auto it2 = it++;
    auto it3 = it++;
    l1 = getLightest(*it, *it2, *it3);
    it++;
    auto it5 = it++;
    l = getLightest(l1, *it, *it5);
    unsorted.erase(l);
    W[1] = l;
    //second coin sorted
    if(TESTING) cerr << "W[1] = " << l << "\n";

    it = unsorted.begin();
    it2 = it++;
    it3 = it++;
    l1 = getLightest(*it, *it2, *it3);
    auto othern = unsorted.begin();
    if(*othern == l1) othern++;
    it++;
    l2 = getLightest(l1, *othern, *it);
    unsorted.erase(l2);
    W[2] = l2;
    //third coin sorted;
    if(TESTING) cerr << "W[2] = " << l2 << "\n";

    it = unsorted.begin();
    it2 = it++;
    it3 = it++;
    l1 = getLightest(*it, *it2, *it3);
    W[3] = l1;
    if(TESTING) cerr << "W[3] = " << l1 << "\n";

    l2 = getMedian(*it, *it2, *it3);
    W[4] = l2;
    if(TESTING) cerr << "W[4] = " << l2 << "\n";

    unsorted.erase(l1);
    unsorted.erase(l2);
    l1 = *unsorted.begin();
    W[5] = l1;
    if(TESTING) cerr << "W[5] = " << l1 << "\n";

    answer(W);
}

#if TESTING

int main() {

    int T, i;

    T = _getNumberOfTests();
    init(T);

    for (i = 1; i <= T; i++) {
        _initNewTest();
        orderCoins();
    }
    
    return 0;
}

#endif

Compilation message

scales.cpp: In function 'void init(int)':
scales.cpp:67:15: warning: unused parameter 'T' [-Wunused-parameter]
   67 | void init(int T)
      |           ~~~~^
# 결과 실행 시간 메모리 Grader output
1 Partially correct 0 ms 256 KB Output is partially correct
2 Partially correct 1 ms 256 KB Output is partially correct
3 Partially correct 0 ms 256 KB Output is partially correct
4 Partially correct 0 ms 256 KB Output is partially correct
5 Partially correct 0 ms 256 KB Output is partially correct
6 Partially correct 0 ms 256 KB Output is partially correct
7 Partially correct 0 ms 256 KB Output is partially correct
8 Partially correct 0 ms 256 KB Output is partially correct
9 Partially correct 1 ms 256 KB Output is partially correct
10 Partially correct 0 ms 256 KB Output is partially correct
11 Partially correct 0 ms 256 KB Output is partially correct
12 Partially correct 1 ms 256 KB Output is partially correct
13 Partially correct 0 ms 256 KB Output is partially correct
14 Partially correct 0 ms 256 KB Output is partially correct
15 Partially correct 0 ms 256 KB Output is partially correct
16 Partially correct 0 ms 256 KB Output is partially correct
17 Partially correct 1 ms 256 KB Output is partially correct
18 Partially correct 1 ms 256 KB Output is partially correct
19 Partially correct 0 ms 256 KB Output is partially correct
20 Partially correct 0 ms 256 KB Output is partially correct
21 Partially correct 1 ms 256 KB Output is partially correct
22 Partially correct 0 ms 256 KB Output is partially correct
23 Partially correct 0 ms 256 KB Output is partially correct
24 Partially correct 0 ms 256 KB Output is partially correct
25 Partially correct 0 ms 256 KB Output is partially correct
26 Partially correct 0 ms 256 KB Output is partially correct
27 Partially correct 0 ms 256 KB Output is partially correct
28 Partially correct 1 ms 256 KB Output is partially correct
29 Partially correct 0 ms 256 KB Output is partially correct
30 Partially correct 0 ms 256 KB Output is partially correct
31 Partially correct 0 ms 256 KB Output is partially correct
32 Partially correct 0 ms 256 KB Output is partially correct
33 Partially correct 0 ms 256 KB Output is partially correct
34 Partially correct 0 ms 256 KB Output is partially correct
35 Partially correct 0 ms 256 KB Output is partially correct
36 Partially correct 0 ms 256 KB Output is partially correct
37 Partially correct 0 ms 256 KB Output is partially correct
38 Partially correct 0 ms 256 KB Output is partially correct
39 Partially correct 0 ms 256 KB Output is partially correct
40 Partially correct 1 ms 256 KB Output is partially correct