結果
| 問題 |
No.2154 あさかつの参加人数
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-10-18 15:35:40 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 1,002 ms / 2,000 ms |
| コード長 | 5,706 bytes |
| コンパイル時間 | 2,997 ms |
| コンパイル使用メモリ | 246,916 KB |
| 実行使用メモリ | 11,136 KB |
| 最終ジャッジ日時 | 2024-09-18 11:45:23 |
| 合計ジャッジ時間 | 26,364 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 25 |
ソースコード
#line 1 "test/yukicoder/2154__imos.test.cpp"
#define PROBLEM "https://yukicoder.me/problems/no/2154"
#line 2 "datastructure/imos.hpp"
#line 2 "common/alias.hpp"
#include <bits/stdc++.h>
// #include <gmpxx.h>
// #include <boost/multiprecision/cpp_int.hpp>
#line 2 "common/print.hpp"
#line 4 "common/print.hpp"
using namespace std;
// ---------------
// ----- TOC -----
template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p);
template <typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p);
template <typename T> ostream &operator<<(ostream &os, const vector<T> &v);
template <typename T>
ostream &operator<<(ostream &os, const vector<vector<T>> &v);
template <typename T>
ostream &operator<<(ostream &os, const vector<vector<vector<T>>> &v);
template <typename T> istream &operator>>(istream &is, vector<T> &v);
template <typename T, typename S>
ostream &operator<<(ostream &os, const map<T, S> &mp);
template <typename T> ostream &operator<<(ostream &os, const set<T> &st);
template <typename T> ostream &operator<<(ostream &os, const multiset<T> &st);
template <typename T> ostream &operator<<(ostream &os, queue<T> q);
template <typename T> ostream &operator<<(ostream &os, deque<T> q);
template <typename T> ostream &operator<<(ostream &os, stack<T> st);
template <class T, class Container, class Compare>
ostream &operator<<(ostream &os, priority_queue<T, Container, Compare> pq);
// --- END TOC ---
// ---------------
template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
os << "(" << p.first << "," << p.second << ")";
return os;
}
template <typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) {
is >> p.first >> p.second;
return is;
}
template <typename T> ostream &operator<<(ostream &os, const vector<T> &v) {
os << "[";
for (int i = 0; i < (int)v.size(); i++) {
os << v[i] << (i + 1 != (int)v.size() ? ", " : "]");
}
return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<vector<T>> &v) {
for (int i = 0; i < (int)v.size(); i++) {
os << v[i] << endl;
}
return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<vector<vector<T>>> &v) {
for (int i = 0; i < (int)v.size(); i++) {
os << "i = " << i << endl;
os << v[i];
}
return os;
}
template <typename T> istream &operator>>(istream &is, vector<T> &v) {
for (T &in : v)
is >> in;
return is;
}
template <typename T, typename S>
ostream &operator<<(ostream &os, const map<T, S> &mp) {
for (auto &[key, val] : mp) {
os << key << ":" << val << " ";
}
return os;
}
template <typename T> ostream &operator<<(ostream &os, const set<T> &st) {
os << "{";
auto itr = st.begin();
for (int i = 0; i < (int)st.size(); i++) {
os << *itr << (i + 1 != (int)st.size() ? ", " : "}");
itr++;
}
return os;
}
template <typename T> ostream &operator<<(ostream &os, const multiset<T> &st) {
auto itr = st.begin();
for (int i = 0; i < (int)st.size(); i++) {
os << *itr << (i + 1 != (int)st.size() ? " " : "");
itr++;
}
return os;
}
template <typename T> ostream &operator<<(ostream &os, queue<T> q) {
while (q.size()) {
os << q.front() << " ";
q.pop();
}
return os;
}
template <typename T> ostream &operator<<(ostream &os, deque<T> q) {
while (q.size()) {
os << q.front() << " ";
q.pop_front();
}
return os;
}
template <typename T> ostream &operator<<(ostream &os, stack<T> st) {
while (st.size()) {
os << st.top() << " ";
st.pop();
}
return os;
}
template <class T, class Container, class Compare>
ostream &operator<<(ostream &os, priority_queue<T, Container, Compare> pq) {
while (pq.size()) {
os << pq.top() << " ";
pq.pop();
}
return os;
}
#line 8 "common/alias.hpp"
using namespace std;
// using namespace boost::multiprecision;
// --- 型エイリアス ---
using ll = long long;
template <typename T> using vec = vector<T>;
template <typename T> using vvec = vector<vector<T>>;
template <typename T> using p_queue = priority_queue<T>;
template <typename T> using rp_queue = priority_queue<T, vec<T>, greater<T>>;
// --- 黒魔術 ---
#define int ll
// --- 制御マクロ ---
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define all(v) begin(v), end(v)
#define BIT(n) (1LL << (n))
#define MAX(type) numeric_limits<type>::max()
#define MIN(type) numeric_limits<type>::min()
#define yes cout << "Yes" << endl
#define no cout << "No" << endl
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
// --- 定数 ---
constexpr ll INF = 1LL << 60;
#line 4 "datastructure/imos.hpp"
template<typename T>
struct imos{
private:
int _n;
vec<T> _data, _raw;
bool _is_build = false;
public:
imos(int n) : _n(n), _data(_n+1, 0), _raw(_n, 0) {}
imos(vec<T> src) : _n(src.size()), _data(_n+1, 0), _raw(_n, 0) {
rep(i, _n) add(i, src[i]);
}
inline void add(int l, int r, T x) {
assert(l < r);
assert(0 <= l && r <= _n);
_is_build = false;
_data[l] += x;
_data[r] -= x;
}
inline void add(int i, T x) {
assert(0 <= i && i < _n);
_is_build = false;
add(i, i+1, x);
}
inline void build() {
_raw[0] = _data[0];
for(int i=1; i<_n; i++) _raw[i] = _raw[i-1] + _data[i];
_is_build = true;
}
inline T get(int i) {
assert(0 <= i && i < _n);
if (!_is_build) build();
return _raw[i];
}
};
#line 4 "test/yukicoder/2154__imos.test.cpp"
signed main() {
int N, M;
cin >> N >> M;
imos<ll> imos(N);
rep(i, M) {
int l, r;
cin >> l >> r;
imos.add(N-l, N-r+1, 1);
}
rep(i, N) {
cout << imos.get(i) << endl;
}
}