結果

問題 No.2736 About half
ユーザー comaviuscomavius
提出日時 2024-04-20 10:45:46
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 18,816 bytes
コンパイル時間 3,065 ms
コンパイル使用メモリ 257,540 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-12 06:20:10
合計ジャッジ時間 3,699 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,248 KB
testcase_02 AC 2 ms
5,248 KB
testcase_03 AC 2 ms
5,248 KB
testcase_04 AC 2 ms
5,248 KB
testcase_05 AC 2 ms
5,248 KB
testcase_06 AC 2 ms
5,248 KB
testcase_07 AC 2 ms
5,248 KB
testcase_08 AC 2 ms
5,248 KB
testcase_09 AC 2 ms
5,248 KB
testcase_10 AC 2 ms
5,248 KB
testcase_11 AC 2 ms
5,248 KB
testcase_12 AC 1 ms
5,248 KB
testcase_13 AC 2 ms
5,248 KB
testcase_14 AC 2 ms
5,248 KB
testcase_15 AC 2 ms
5,248 KB
testcase_16 AC 2 ms
5,248 KB
testcase_17 AC 2 ms
5,248 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma region //comavius::competitive library

#pragma region //inclusion and optimization
#include <bits/stdc++.h>
#ifdef IS_TEST
static const bool IS_TEST_ENVIROMENT = true;
#else
static const bool IS_TEST_ENVIROMENT = false;
#endif
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma endregion //inclusion and optimization

namespace comavius::competitive { //typedefs

    #pragma region //long long
        typedef long long ll;
        typedef std::vector<ll> vll;
        typedef std::vector<vll> vvll;
        typedef std::vector<vvll> vvvll;
        typedef std::map<ll, ll> mll;
        typedef std::map<ll, mll> mmll;
        typedef std::pair<ll, ll> pll;
        typedef std::vector<pll> vpll;
    #pragma endregion //long long

    #pragma region //long double
        typedef long double ld;
        typedef std::vector<ld> vld;
        typedef std::vector<vld> vvld;
        typedef std::vector<vvld> vvvld;
    #pragma endregion //long double

    #pragma region //std::string
    typedef std::string str;
    typedef std::vector<str> vstr;
    typedef std::vector<vstr> vvstr;
    typedef std::vector<vvstr> vvvstr;
    #pragma endregion //std::string

    #pragma region //bool
        typedef std::vector<bool> vb;
        typedef std::vector<vb> vvb;
        typedef std::vector<vvb> vvvb;
    #pragma endregion //bool

    #pragma region //char
        typedef std::vector<char> vc;
        typedef std::vector<vc> vvc;
        typedef std::vector<vvc> vvvc;
    #pragma endregion //char

    #pragma region //container of std
        #pragma region //std::vector
            template <typename T>
            using vec = std::vector<T>;
            template <typename T>
            using vec2 = std::vector<std::vector<T>>;
            template <typename T>
            using vec3 = std::vector<std::vector<std::vector<T>>>;
            template <typename T>
            using vec4 = std::vector<std::vector<std::vector<std::vector<T>>>>;
            template <typename T>
            using vec5 = std::vector<std::vector<std::vector<std::vector<std::vector<T>>>>>;
            template <typename T>
            using vec6 = std::vector<std::vector<std::vector<std::vector<std::vector<std::vector<T>>>>>>;
            template <typename T>
            using vec7 = std::vector<std::vector<std::vector<std::vector<std::vector<std::vector<std::vector<T>>>>>>>;
        #pragma endregion //std::vector
    #pragma endregion //container of std

} // namespace comavius::competitive typedefs

namespace comavius::competitive::sfinae { //SFINAE : breaking changes are prohibited

    #pragma region //has_mul_op
        template <typename T, typename = void>
        struct has_multiply_operator : std::false_type {};
        template <typename T>
        struct has_multiply_operator<T, std::void_t<decltype(std::declval<T>() * std::declval<T>())>> : std::true_type {};
    #pragma endregion //has_mul_op

    #pragma region //has_forward_iterator
        template<typename T, typename = void>
        struct has_forward_iterator {
            static constexpr bool value = false;
        };

        template<typename T>
        struct has_forward_iterator<T, std::void_t<
            decltype(std::begin(std::declval<T&>())),
            decltype(std::end(std::declval<T&>())),
            typename T::iterator,  // Tがiterator型を持つ
            decltype(++std::declval<typename T::iterator&>()),
            decltype(*std::declval<typename T::iterator&>()),
            decltype(std::declval<typename T::iterator&>() == std::declval<typename T::iterator&>()),
            decltype(std::declval<typename T::iterator&>() != std::declval<typename T::iterator&>()),
            decltype(std::declval<typename T::iterator&>() = std::declval<const typename T::iterator&>())
        >> {
            static constexpr bool value = true;
        };
    #pragma endregion //has_forward_iterator
}

namespace comavius::competitive::algebraic_structures {
    //work in progress
    /*
    template <typename T>
    struct Monoid {
        
    };
    */
}

namespace comavius::competitive { //BFS
    
    class BFS {
        std::vector<std::vector<long long>> adjacency_list;
        long long number_of_nodes;

        public:
        BFS(std::vector<std::vector<long long>> adjacency_list_, long long number_of_nodes_) {
            this->adjacency_list = adjacency_list_;
            this->number_of_nodes = number_of_nodes_;
        }

        long long run(long long start_node, long long end_node) {
            std::vector<bool> visited(number_of_nodes, false);
            std::vector<long long> current_queue(1, start_node), next_queue;
            visited[start_node] = true;
            long long distance = 0;
            if (start_node == end_node) {
                return distance;
            }
            while (current_queue.size() != 0) {
                distance++;
                next_queue.clear();
                for (auto i: current_queue) {
                    if (i == end_node) {
                        return distance;
                    }
                    for (auto j: adjacency_list[i]) {
                        if (!visited[j]) {
                            visited[j] = true;
                            next_queue.push_back(j);
                            if (j == end_node) {
                                return distance;
                            }
                        }
                    }
                }
                current_queue = next_queue;
            }
            return (long long)-1;
        }
    };
} // namespace comavius::competitive::BFS

namespace comavius::competitive { //UnionFind

    class UnionFind {
        std::vector<long long> parent;
        std::vector<long long> rank;
        std::vector<long long> size;
        std::vector<long long> edge_count;


        public:
        UnionFind(long long num_nodes) {
            parent.resize(num_nodes, -1);
            rank.resize(num_nodes, 0);
            size.resize(num_nodes, 1);
            edge_count.resize(num_nodes, 0);
        }

        long long root_of(long long x) {
            if (parent[x] == -1) {
                return x;
            }
            else {
                return parent[x] = root_of(parent[x]);
            }
        }

        void unite(long long x, long long y) {
            long long rx = root_of(x);
            long long ry = root_of(y);
            if (rx == ry) {
                edge_count[rx]++;
                return;
            }
            else if (rank[rx] < rank[ry]) {
                parent[rx] = ry;
                size[ry] += size[rx];
                edge_count[ry] += edge_count[rx] + 1;
            } else {
                parent[ry] = rx;
                size[rx] += size[ry];
                if (rank[rx] == rank[ry]) rank [rx]++;
                edge_count[rx] += edge_count[ry] + 1;
            }
            return;
        }

        bool is_same(long long x, long long y) {
            return root_of(x) == root_of(y);
        }

        long long size_of(long long x) {
            return size[root_of(x)];
        }
        bool is_cycle(long long x) {
            return edge_count[root_of(x)] >= size[root_of(x)];
        }
    };
} // namespace comavius::competitive::UnionFind

namespace comavius::competitive { //get_primes

    std::vector<long long> get_primes(long long n) {
        std::vector<bool> is_prime(n + 1, true);
        std::vector<long long> primes;
        is_prime[0] = false;
        is_prime[1] = false;
        for (long long i = 2; i <= n; i++) {
            if (is_prime[i]) {
                primes.push_back(i);
                for (long long j = 2 * i; j <= n; j += i) {
                    is_prime[j] = false;
                }
            }
        }
        return primes;
    }
} // namespace comavius::competitive::get_primes

namespace comavius::competitive { //fast pow (repeated squaring)

    template <typename T>
    T fast_pow(T base, T neutral, long long exponent) {
        //check if T has multiply operator
        static_assert(sfinae::has_multiply_operator<T>::value, "comavius::competitive::fast_pow : T must have operator*");
        T ans = neutral;
        while (exponent > 0) {
            if (exponent % 2 == 1) {
                ans *= base;
            }
            base *= base;
            exponent /= 2;
        }
        return ans;
    }
} // namespace comavius::competitive::fast_pow

namespace comavius::competitive { //bipartite matching
    /*
    class BipartiteMatching {
        long long size, size_u, size_v;
        std::vector<long long> nodes_u, nodes_v;
        std::vector<std::vector<long long>> adjacency_list;

    };
    */
}

namespace comavius::competitive { // chmax/chmin
    template <typename T>
    concept HasMaxOverload = requires(T a, T b) {
        { std::max(a, b) } -> std::convertible_to<T>;
    };
    template <typename T>
    concept HasMinOverload = requires(T a, T b) {
        { std::min(a, b) } -> std::convertible_to<T>;
    };

    template <HasMaxOverload T>
    void chmax(T& a, T b) {
        a = std::max(a, b);
    }

    template <HasMinOverload T>
    void chmin(T& a, T b) {
        a = std::min(a, b);
    }

}

namespace comavius::competitive { //Print(stdout, stderr)

    #pragma region //formatting various type of values
        //is_vector structure
        template <typename T>
        struct is_vector : std::false_type {};
        template <typename T>
        struct is_vector<std::vector<T>> : std::true_type {};
        //is_pair structure
        template <typename T>
        struct is_pair : std::false_type {};
        template <typename T, typename U>
        struct is_pair<std::pair<T, U>> : std::true_type {};
        //is_iterator structure
        template <typename T, typename = void>
        struct is_iterator : std::false_type {};
        template <typename T>
        struct is_iterator<
            T,
            typename std::enable_if<
                !std::is_same<
                    typename std::iterator_traits<T>::value_type,
                    void
                >
                ::value>
            ::type
        > : std::true_type {};
        //generate std::string for stdout/stderr
        //std::string
        std::string generate_string(std::string s) {
            return s + " ";
        }
        //char
        std::string generate_string(char c) {
            return std::string(1, c) + " ";
        }
        //eger types
        template <typename T>
        typename std::enable_if_t<std::is_integral<T>::value, std::string>
        generate_string(T t) {
            return std::to_string(t) + " ";
        }
        //floating point types
        template <typename T>
        typename std::enable_if_t<std::is_floating_point<T>::value, std::string>
        generate_string(T t) {
            return std::to_string(t) + " ";
        }
        // container with forward iterator
        template <typename T>
        typename std::enable_if_t<sfinae::has_forward_iterator<T>::value, std::string>
        generate_string(T t) {
            std::string s = "";
            for (auto i = t.begin(); i != t.end(); i++) {
                s += generate_string(*i);
                s += " ";
            }
            s += "\n";
            return s;
        }
        //std::pair
        template <typename T>
        typename std::enable_if_t<is_pair<T>::value, std::string>
        generate_string(T t) {
            return generate_string(t.first) + generate_string(t.second);
        }
        //std::iterator
        template <typename T>
        typename std::enable_if_t<is_iterator<T>::value, std::string>
        generate_string(T begin, T end) {
            std::string s = "";
            for (auto i = begin; i != end; i++) {
                s += generate_string(*i);
                s += " ";
            }
            s += "\n";
            return s;
        }
    #pragma endregion //formatting various type of values

    //color enum-class
    enum class Color {
        BLACK,
        RED,
        GREEN,
        YELLOW,
        BLUE,
        MAGENTA,
        CYAN,
        WHITE,
        DEFAULT
    };

    //ansi code color
    std::string get_ansi_color(Color color) {
        if (IS_TEST_ENVIROMENT) {
            std::string ansi_code;
            switch (color) {
                case Color::BLACK:
                    ansi_code = "\033[30m\033[1m";
                    break;
                case Color::RED:
                    ansi_code = "\033[31m\033[1m";
                    break;
                case Color::GREEN:
                    ansi_code = "\033[32m\033[1m";
                    break;
                case Color::YELLOW:
                    ansi_code = "\033[33m\033[1m";
                    break;
                case Color::BLUE:
                    ansi_code = "\033[34m\033[1m";
                    break;
                case Color::MAGENTA:
                    ansi_code = "\033[35m\033[1m";
                    break;
                case Color::CYAN:
                    ansi_code = "\033[36m\033[1m";
                    break;
                case Color::WHITE:
                    ansi_code = "\033[37m";
                    break;
                case Color::DEFAULT:
                    ansi_code = "\033[0m";
                    break;
            }
            return ansi_code;
        }
        else {
            return "";
        }

    }

    #pragma region //Print to stdout
        //default color(native)
        template <typename T>
        void print(T t) {
            std::cout << generate_string(t);
        }
        // with iterator range
        template <typename T>
        void print(T begin, T end) {
            std::cout << generate_string(begin, end);
        }
        //print"ln"
        template <typename T>
        void println(T t) {
            print(t);
            std::cout << "\n";
        }
        //print"ln" with iterator range
        template <typename T>
        void println(T begin, T end) {
            print(begin, end);
            std::cout << "\n";
        }
        //yes or no
        void yneos(bool a) {
            if (a) {
                println("Yes");
            }
            else {
                println("No");
            }
        }
    #pragma endregion //Print to stdout

    #pragma region //ePrint to stderr
        //default color(Color::CYAN)
        template <typename T>
        void errprint(T t) {
            if (IS_TEST_ENVIROMENT) {
                std::cerr << get_ansi_color(Color::RED) << generate_string(t) << get_ansi_color(Color::DEFAULT);
            }
        }
        //set color
        template <typename T>
        void errprint(T t, Color color) {
            if (IS_TEST_ENVIROMENT) {
                std::cerr << get_ansi_color(color) << generate_string(t) << get_ansi_color(Color::DEFAULT);
            }
        }
        //print"ln"
        template <typename T>
        void errprintln(T t) {
            if (IS_TEST_ENVIROMENT) {
                errprint(t);
                std::cerr << "\n";
            }
        }
        template <typename T>
        void errprintln(T t, Color color) {
            if (IS_TEST_ENVIROMENT) {
                errprint(t, color);
                std::cerr << "\n";
            }
        }
        //print"ln" with iterator range
        template <typename T>
        void errprintln(T begin, T end) {
            if (IS_TEST_ENVIROMENT) {
                errprint(begin, end);
                std::cerr << "\n";
            }
        }
        template <typename T>
        void errprintln(T begin, T end, Color color) {
            if (IS_TEST_ENVIROMENT) {
                errprint(begin, end, color);
                std::cerr << "\n";
            }
        }
        //debug print
        void debug() {
            errprintln("DEBUG", Color::MAGENTA);
        }
    #pragma endregion //ePrint to stderr

} // namespace comavius::competitive print

namespace comavius::competitive { //initial settings
    void initial_settings() {
        std::ios::sync_with_stdio(false);
        std::cin.tie(nullptr);
        std::cout << std::setprecision(15);
        std::cerr << std::setprecision(15);
    }
} // namespace comavius::competitive::initial_settings

namespace comavius::competitive { //make terminal default

    void make_terminal_default() {
        if (IS_TEST_ENVIROMENT) {
            std::cerr << get_ansi_color(Color::DEFAULT) << "\n\n" << std::endl;
        }
        else {
            std::cerr << std::endl;
        }
    }

}

#pragma region //Read macro
    #define GET_1_ARG(TYPE, ARG); TYPE ARG; std::cin >> ARG;
    #define GET_2_ARG(TYPE, ARG, ...) GET_1_ARG(TYPE, ARG) GET_1_ARG(TYPE, __VA_ARGS__)
    #define GET_3_ARG(TYPE, ARG, ...) GET_1_ARG(TYPE, ARG) GET_2_ARG(TYPE, __VA_ARGS__)
    #define GET_4_ARG(TYPE, ARG, ...) GET_1_ARG(TYPE, ARG) GET_3_ARG(TYPE, __VA_ARGS__)
    #define GET_5_ARG(TYPE, ARG, ...) GET_1_ARG(TYPE, ARG) GET_4_ARG(TYPE, __VA_ARGS__)
    #define GET_6_ARG(TYPE, ARG, ...) GET_1_ARG(TYPE, ARG) GET_5_ARG(TYPE, __VA_ARGS__)
    #define GET_7_ARG(TYPE, ARG, ...) GET_1_ARG(TYPE, ARG) GET_6_ARG(TYPE, __VA_ARGS__)
    #define GET_8_ARG(TYPE, ARG, ...) GET_1_ARG(TYPE, ARG) GET_7_ARG(TYPE, __VA_ARGS__)
    #define GET_9_ARG(TYPE, ARG, ...) GET_1_ARG(TYPE, ARG) GET_8_ARG(TYPE, __VA_ARGS__)
    #define GET_10_ARG(TYPE, ARG, ...) GET_1_ARG(TYPE, ARG) GET_9_ARG(TYPE, __VA_ARGS__)

    #define GET_MACRO(_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,NAME,...) NAME
    #define read(TYPE, ...) GET_MACRO(__VA_ARGS__, GET_10_ARG, GET_9_ARG, GET_8_ARG, GET_7_ARG, GET_6_ARG, GET_5_ARG, GET_4_ARG, GET_3_ARG, GET_2_ARG, GET_1_ARG)(TYPE, __VA_ARGS__)

    #define readv(TYPE, NAME, SIZE) std::vector<TYPE> NAME(SIZE); for (long long i = 0; i < SIZE; i++) std::cin >> NAME[i];
    #define readvv(TYPE, NAME, H, W) std::vector<std::vector<TYPE>> NAME(H, std::vector<TYPE>(W)); for (long long i = 0; i < H; i++) for (long long j = 0; j < W; j++) std::cin >> NAME[i][j];
#pragma endregion //Read macro

#pragma region //Other macro
    #define rep(i, n) for (ll i = 0; i < n; i++)
    #define reps(i, start, goal, diff) for (ll i = start; i != goal; i += diff)
    #define all(a) a.begin(), a.end()
//    #define chmax(a, b) a = std::max(a, b)
//    #define chmin(a, b) a = std::min(a, b)
#pragma endregion //Other macro

#pragma region //namespace expansion
    using namespace std;
    using namespace comavius::competitive;
#pragma endregion //namespace expansion

#pragma endregion //comavius::competitive library


int main() {
    read(ll, a, b);
    if (a * 2 >= b && b * 2 >= a) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}
0