跳到正文

IMGCsir

838568

> 最后在线时间:2026年4月18日17时37分

在洛谷打开
资料、奖项与版本

资料

编号
838568
抓取

奖项

2025 CSP-J
二等奖

https://www.luogu.com.cn/discuss/1174482

florr.io

快读快写

C++
#define LOCAL
namespace ly {
    namespace IO {
#ifndef LOCAL
        #define SIZE (1 << 20)
            char in[SIZE], out[SIZE], *p1 = in, *p2 = in, *p3 = out;
            #define getchar() (p1 == p2 && (p2 = (p1 = in) + fread(in, 1, SIZE, stdin), p1 == p2) ? EOF: *p1++)
            #define flush() (fwrite(p3 = out, 1, SIZE, stdout))
            #define putchar(ch) (p3 == out + SIZE && flush(), *p3++=(ch))
            class Flush {public:~Flush() {flush();}}_;
#endif
        template<typename type>
        inline
        void read(type &x) {
            x = 0;bool flag(0);char ch = getchar();
            while (!isdigit(ch)) flag ^= ch == '-', ch = getchar();
            while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
            flag ? x = -x : 0;
        }
        template<typename type>
        inline
        void write(type x, bool flag = 1) {
            x < 0 ? x = -x, putchar('-') : 0;static short Stack[50], top(0);
            do Stack[++top] = x % 10, x /= 10;while(x);
            while (top) putchar(Stack[top--] | 48);
            flag ? putchar('\n') : putchar(' ');
        }
#ifndef LOCAL
        #undef SIZE
            #undef getchar
            #undef putchar
            #undef flush
#endif
    }
}

using namespace ly::IO;

快读快写优化

C++
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

namespace ly {
    namespace IO {
#ifndef LOCAL
#define SIZE (1 << 20)
        char in[SIZE], out[SIZE], *p1 = in, *p2 = in, *p3 = out;
#define getchar() (p1 == p2 && (p2 = (p1 = in) + fread(in, 1, SIZE, stdin), p1 == p2) ? EOF: *p1++)
#define flush() (fwrite(p3 = out, 1, SIZE, stdout))
#define putchar(ch) (p3 == out + SIZE && flush(), *p3++=(ch))
        class Flush {public:~Flush() {flush();}}_;
#endif
        template<typename type>
        inline
        void read(type &x) {
            x = 0;bool flag(0);char ch = getchar();
            while (!isdigit(ch)) flag ^= ch == '-', ch = getchar();
            while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
            flag ? x = -x : 0;
        }
        template<typename type>
        inline
        void write(type x, bool flag = 1) {
            x < 0 ? x = -x, putchar('-') : 0;static short Stack[50], top(0);
            do Stack[++top] = x % 10, x /= 10;while(x);
            while (top) putchar(Stack[top--] | 48);
            flag ? putchar('\n') : putchar(' ');
        }
#ifndef LOCAL
#undef SIZE
#undef getchar
#undef putchar
#undef flush
#endif
    }
}

using namespace ly::IO;

优先队列

C++
#include <bits/stdc++.h>

using namespace std;

int main() {
  // 大根堆 从大到小
  priority_queue<int> pq;
  pq.push(4);
  pq.push(1);
  pq.push(3);
  pq.push(9);
  pq.push(7);

  cout << pq.top() << endl; // 输出9

  // 小根堆 从小到大,greater可以重载
  priority_queue<int, vector<int>, greater<int>> pq1;
  pq1.push(4);
  pq1.push(1);
  pq1.push(3);
  pq1.push(9);
  pq1.push(7);

  cout << pq1.top() << endl; // 输出1

  return 0;
}

说句闲话,研究珂学的最好方法是

入门赛 #37 作弊名单(棕名 143 人,封 16 人) qinhzexuan

LGR-231 比赛违规名单 tyz215

还没有收录这位用户的文章。