library

This documentation is automatically generated by online-judge-tools/verification-helper

View the Project on GitHub gyouzasushi/library

:heavy_check_mark: Monoid: Argmax
(algebra/monoid_argmax.hpp)

Verified with

Code

#pragma once
#include <limits>
template <class T>
struct monoid_argmax {
    struct S {
        T val;
        int id;
    };
    static S op(S a, S b) {
        if (a.val != b.val) return a.val > b.val ? a : b;
        return a.id < b.id ? a : b;
    }
    static S e() {
        return {std::numeric_limits<T>::lowest(), -1};
    }
};
#line 2 "algebra/monoid_argmax.hpp"
#include <limits>
template <class T>
struct monoid_argmax {
    struct S {
        T val;
        int id;
    };
    static S op(S a, S b) {
        if (a.val != b.val) return a.val > b.val ? a : b;
        return a.id < b.id ? a : b;
    }
    static S e() {
        return {std::numeric_limits<T>::lowest(), -1};
    }
};
Back to top page