Submission #1714459


Source Code Expand

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

typedef pair<int, int> pii;
typedef long long ll;
typedef long double lf;

ll cross(pii a, pii b) {
    return 1LL * a.first * b.second - 1LL * a.second * b.first;
}

int P[6], Q[6];

vector<pii> Sum, Conv;

vector<pii> mrg(vector<pii> &a, vector<pii> &b) {
    vector<pii> ret;
    int pos1 = 0, pos2 = 0;
    while(pos1 < a.size() && pos2 < b.size()) {
        if(cross(a[pos1], b[pos2]) <= 0) ret.push_back(a[pos1]), pos1++;
        else ret.push_back(b[pos2]), pos2++;
    }
    while(pos1 < a.size()) ret.push_back(a[pos1]), pos1++;
    while(pos2 < b.size()) ret.push_back(b[pos2]), pos2++;
    return ret;
}

int main() {
    for(int i = 0; i < 6; i++) {
        scanf("%d", &P[i]);
    }
    for(int i = 0; i < 6; i++) {
        scanf("%d", &Q[i]);
    }

    Sum.push_back(pii(-P[0], Q[0]));
    Sum.push_back(pii(P[0], -Q[0]));

    for(int i = 1; i < 6; i++) {
        vector<pii> tmp;
        tmp.push_back(pii(-P[i], Q[i]));
        tmp.push_back(pii(P[i], -Q[i]));

        Sum = mrg(Sum, tmp);
    }

    pii st = pii(0, 0);
    for(int i = 0; i < 6; i++) {
        st.first += P[i];
    }

    Conv.push_back(st);

    for(int i = 0; i < (int)Sum.size() - 1; i++) {
        pii tmp = Conv.back();
        Conv.push_back(pii(tmp.first + Sum[i].first, tmp.second + Sum[i].second));
    }

    lf ans = 0;

    for(int i = 0; i < Conv.size(); i++) {
        pii a = Conv[i];
        pii b = Conv[(i + 1)%Conv.size()];

        if(a.first == a.second || b.first == b.second || ((a.first < a.second) ^ (b.first < b.second))) {
            lf x1 = a.first;
            lf y1 = a.second;
            lf x2 = b.first;
            lf y2 = b.second;
            if(a.first == b.first) ans = max(ans, x1);
            else ans = max(ans, (y1 - (y2 - y1) / (x2 - x1) * x1) / (1 - (y2 - y1) / (x2 - x1)));
        }
        else if(a.first < a.second) ans = max(ans, max(a.first, b.first));
        else ans = max(ans, max(a.second, b.second));
    }

    cout<<fixed;
    cout.precision(20);
    cout << ans / 100;
}

Submission Info

Submission Time
Task D - Dice Game
User choikiwon
Language C++14 (GCC 5.4.1)
Score 0
Code Size 2147 Byte
Status CE

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:73:73: error: no matching function for call to ‘max(lf&, const int&)’
         else if(a.first < a.second) ans = max(ans, max(a.first, b.first));
                                                                         ^
In file included from /usr/include/c++/5/bits/char_traits.h:39:0,
                 from /usr/include/c++/5/ios:40,
                 from /usr/include/c++/5/istream:38,
                 from /usr/include/c++/5/sstream:38,
                 from /usr/include/c++/5/complex:45,
                 from /usr/include/c++/5/ccomplex:38,
                 from /usr/include/x86_64-linux-gnu/c++/5/bits/stdc++.h:52,
                 from ./Main.cpp:1:
/usr/include/c++/5/bits/stl_algobase.h:219:5: note: candidate: template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)
     max(const _Tp& __a, const _Tp& __b)
     ^
/usr/include/c++/5/bits/stl_algobase.h:219:5: note:   template argument deduction/substitution failed:
./Main.cpp:73:73: note:  ...