Submission #67532472
Source Code Expand
#include <algorithm>
#include <array>
#include <bit>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define FOR(i, n, m) for (int i = n; i < (int)m; ++i)
#define REP(i, n) FOR (i, 0, n)
#define ALL(v) v.begin(), v.end()
#define PB push_back
using namespace std;
using ll = long long;
constexpr long long INF = 1000000000;
constexpr long long MOD = 998244353;
using P = pair<int, int>;
const std::string COLOR_RESET = "\033[0m", BRIGHT_GREEN = "\033[1;32m",
BRIGHT_RED = "\033[1;31m", BRIGHT_CYAN = "\033[1;36m",
NORMAL_CROSSED = "\033[0;9;37m",
RED_BACKGROUND = "\033[1;41m", NORMAL_FAINT = "\033[0;2m";
#ifdef LOCAL
#define dbg(x) \
std::cerr << BRIGHT_CYAN << #x << COLOR_RESET << " = " << (x) \
<< NORMAL_FAINT << " (L" << __LINE__ << ") " << __FILE__ \
<< COLOR_RESET << std::endl
#define dbgif(cond, x) \
((cond) ? std::cerr << BRIGHT_CYAN << #x << COLOR_RESET << " = " << (x) \
<< NORMAL_FAINT << " (L" << __LINE__ << ") " \
<< __FILE__ << COLOR_RESET << std::endl \
: std::cerr)
#define msg(s) \
std::cerr << BRIGHT_GREEN << s << NORMAL_FAINT << " (L" << __LINE__ \
<< ") " << __FILE__ << COLOR_RESET << std::endl
#else
#define dbg(x) 0
#define dbgif(cond, x) 0
#define msg(s) 0
#endif
template <typename T>
inline bool chmax(T &a, T b) {
return a < b && (a = b, true);
}
template <typename T>
inline bool chmin(T &a, T b) {
return a > b && (a = b, true);
}
template <class T1, class T2>
std::pair<T1, T2> operator+(const std::pair<T1, T2> &l,
const std::pair<T1, T2> &r) {
return std::make_pair(l.first + r.first, l.second + r.second);
}
template <class T1, class T2>
std::pair<T1, T2> operator-(const std::pair<T1, T2> &l,
const std::pair<T1, T2> &r) {
return std::make_pair(l.first - r.first, l.second - r.second);
}
template <class T>
std::vector<T> sort_unique(std::vector<T> vec) {
sort(vec.begin(), vec.end()),
vec.erase(unique(vec.begin(), vec.end()), vec.end());
return vec;
}
template <class IStream, class T>
IStream &operator>>(IStream &is, std::vector<T> &vec) {
for (auto &v : vec) is >> v;
return is;
}
template <class OStream, class T>
OStream &operator<<(OStream &os, const std::vector<T> &vec);
template <class OStream, class T, size_t sz>
OStream &operator<<(OStream &os, const std::array<T, sz> &arr);
template <class OStream, class T, class TH>
OStream &operator<<(OStream &os, const std::unordered_set<T, TH> &vec);
template <class OStream, class T, class U>
OStream &operator<<(OStream &os, const std::pair<T, U> &pa);
template <class OStream, class T>
OStream &operator<<(OStream &os, const std::deque<T> &vec);
template <class OStream, class T>
OStream &operator<<(OStream &os, const std::set<T> &vec);
template <class OStream, class T>
OStream &operator<<(OStream &os, const std::multiset<T> &vec);
template <class OStream, class T>
OStream &operator<<(OStream &os, const std::unordered_multiset<T> &vec);
template <class OStream, class T, class U>
OStream &operator<<(OStream &os, const std::pair<T, U> &pa);
template <class OStream, class TK, class TV>
OStream &operator<<(OStream &os, const std::map<TK, TV> &mp);
template <class OStream, class TK, class TV, class TH>
OStream &operator<<(OStream &os, const std::unordered_map<TK, TV, TH> &mp);
template <class OStream, class... T>
OStream &operator<<(OStream &os, const std::tuple<T...> &tpl);
template <class OStream, class T>
OStream &operator<<(OStream &os, const std::vector<T> &vec) {
os << '[';
for (auto v : vec) os << v << ',';
os << ']';
return os;
}
template <class OStream, class T, size_t sz>
OStream &operator<<(OStream &os, const std::array<T, sz> &arr) {
os << '[';
for (auto v : arr) os << v << ',';
os << ']';
return os;
}
template <class... T>
std::istream &operator>>(std::istream &is, std::tuple<T...> &tpl) {
std::apply([&is](auto &&...args) { ((is >> args), ...); }, tpl);
return is;
}
template <class OStream, class... T>
OStream &operator<<(OStream &os, const std::tuple<T...> &tpl) {
os << '(';
std::apply([&os](auto &&...args) { ((os << args << ','), ...); }, tpl);
return os << ')';
}
template <class OStream, class T, class TH>
OStream &operator<<(OStream &os, const std::unordered_set<T, TH> &vec) {
os << '{';
for (auto v : vec) os << v << ',';
os << '}';
return os;
}
template <class OStream, class T>
OStream &operator<<(OStream &os, const std::deque<T> &vec) {
os << "deq[";
for (auto v : vec) os << v << ',';
os << ']';
return os;
}
template <class OStream, class T>
OStream &operator<<(OStream &os, const std::set<T> &vec) {
os << '{';
for (auto v : vec) os << v << ',';
os << '}';
return os;
}
template <class OStream, class T>
OStream &operator<<(OStream &os, const std::multiset<T> &vec) {
os << '{';
for (auto v : vec) os << v << ',';
os << '}';
return os;
}
template <class OStream, class T>
OStream &operator<<(OStream &os, const std::unordered_multiset<T> &vec) {
os << '{';
for (auto v : vec) os << v << ',';
os << '}';
return os;
}
template <class OStream, class T, class U>
OStream &operator<<(OStream &os, const std::pair<T, U> &pa) {
return os << '(' << pa.first << ',' << pa.second << ')';
}
template <class OStream, class TK, class TV>
OStream &operator<<(OStream &os, const std::map<TK, TV> &mp) {
os << '{';
for (auto v : mp) os << v.first << "=>" << v.second << ',';
os << '}';
return os;
}
template <class OStream, class TK, class TV, class TH>
OStream &operator<<(OStream &os, const std::unordered_map<TK, TV, TH> &mp) {
os << '{';
for (auto v : mp) os << v.first << "=>" << v.second << ',';
os << '}';
return os;
}
struct Watch {
using Clock = std::chrono::high_resolution_clock;
using TimePoint = std::chrono::time_point<Clock>;
TimePoint start_time;
std::chrono::duration<double> elapsed;
bool running;
Watch() : elapsed(0), running(false) {}
void start() {
if (!running) {
start_time = Clock::now();
running = true;
}
}
void stop() {
if (running) {
elapsed += Clock::now() - start_time;
running = false;
}
}
double elapsed_seconds() const {
if (running) {
return elapsed.count() +
std::chrono::duration<double>(Clock::now() - start_time)
.count();
} else {
return elapsed.count();
}
}
void reset() {
running = false;
elapsed = std::chrono::duration<double>::zero();
}
};
struct modint {
ll n;
public:
modint(const ll n = 0) : n((n % MOD + MOD) % MOD) {}
static modint pow(modint a, int m) {
modint r = 1;
while (m > 0) {
if (m & 1) {
r *= a;
}
a = (a * a);
m /= 2;
}
return r;
}
modint &operator++() {
*this += 1;
return *this;
}
modint &operator--() {
*this -= 1;
return *this;
}
modint operator++(int) {
modint ret = *this;
*this += 1;
return ret;
}
modint operator--(int) {
modint ret = *this;
*this -= 1;
return ret;
}
modint operator~() const { return (this->pow(n, MOD - 2)); } // inverse
friend bool operator==(const modint &lhs, const modint &rhs) {
return lhs.n == rhs.n;
}
friend bool operator<(const modint &lhs, const modint &rhs) {
return lhs.n < rhs.n;
}
friend bool operator>(const modint &lhs, const modint &rhs) {
return lhs.n > rhs.n;
}
friend modint &operator+=(modint &lhs, const modint &rhs) {
lhs.n += rhs.n;
if (lhs.n >= MOD) lhs.n -= MOD;
return lhs;
}
friend modint &operator-=(modint &lhs, const modint &rhs) {
lhs.n -= rhs.n;
if (lhs.n < 0) lhs.n += MOD;
return lhs;
}
friend modint &operator*=(modint &lhs, const modint &rhs) {
lhs.n = (lhs.n * rhs.n) % MOD;
return lhs;
}
friend modint &operator/=(modint &lhs, const modint &rhs) {
lhs.n = (lhs.n * (~rhs).n) % MOD;
return lhs;
}
friend modint operator+(const modint &lhs, const modint &rhs) {
return modint(lhs.n + rhs.n);
}
friend modint operator-(const modint &lhs, const modint &rhs) {
return modint(lhs.n - rhs.n);
}
friend modint operator*(const modint &lhs, const modint &rhs) {
return modint(lhs.n * rhs.n);
}
friend modint operator/(const modint &lhs, const modint &rhs) {
return modint(lhs.n * (~rhs).n);
}
};
istream &operator>>(istream &is, modint m) {
is >> m.n;
return is;
}
ostream &operator<<(ostream &os, modint m) {
os << m.n;
return os;
}
#define MAX_N 10000000
long long extgcd(long long a, long long b, long long &x, long long &y) {
long long d = a;
if (b != 0) {
d = extgcd(b, a % b, y, x);
y -= (a / b) * x;
} else {
x = 1;
y = 0;
}
return d;
}
long long mod_inverse(long long a, long long m) {
long long x, y;
if (extgcd(a, m, x, y) == 1) return (m + x % m) % m;
else return -1;
}
vector<long long> fact(MAX_N + 1, INF), fact_inv(MAX_N + 1, INF);
modint mod_comb(long long n, long long k) {
if (n < 0 || k < 0 || n < k) return 0;
if (fact[0] == INF) {
fact[0] = 1;
for (ll i = 1; i <= MAX_N; ++i) {
fact[i] = (fact[i - 1] * i) % MOD;
}
fact_inv[MAX_N] = mod_inverse(fact[MAX_N], MOD);
for (ll i = MAX_N - 1; i >= 0; i--) {
fact_inv[i] = (fact_inv[i + 1] * (i + 1)) % MOD;
}
}
return (((fact[n] * fact_inv[k]) % MOD) * fact_inv[n - k]) % MOD;
}
using mi = modint;
mi mod_pow(mi a, ll n) {
mi ret = 1;
mi tmp = a;
while (n > 0) {
if (n % 2) ret *= tmp;
tmp = tmp * tmp;
n /= 2;
}
return ret;
}
struct UnionFind {
vector<int> data;
vector<int> a;
vector<int> b;
UnionFind() = default;
explicit UnionFind(size_t sz) : data(sz, -1), a(sz, 0), b(sz, 0) {}
int unite(int x, int y) {
x = find(x), y = find(y);
if (x == y) return false;
if (data[x] > data[y]) swap(x, y);
data[x] += data[y];
data[y] = x;
a[x] += a[y];
b[x] += b[y];
int ret = min(a[x], b[x]);
a[x] -= ret;
b[x] -= ret;
return ret;
}
int find(int k) {
if (data[k] < 0) return (k);
return data[k] = find(data[k]);
}
int size(int k) { return -data[find(k)]; }
bool same(int x, int y) { return find(x) == find(y); }
vector<vector<int>> groups() {
int n = (int)data.size();
vector<vector<int>> ret(n);
for (int i = 0; i < n; ++i) {
ret[find(i)].emplace_back(i);
}
ret.erase(remove_if(begin(ret), end(ret),
[&](const vector<int> &v) { return v.empty(); }),
end(ret));
return ret;
}
};
template <typename T>
struct BinaryIndexedTree {
private:
int n;
vector<T> data;
public:
BinaryIndexedTree() = default;
explicit BinaryIndexedTree(int n) : n(n) { data.assign(n + 1, T()); }
explicit BinaryIndexedTree(const vector<T> &v)
: BinaryIndexedTree((int)v.size()) {
build(v);
}
void build(const vector<T> &v) {
assert(n == (int)v.size());
for (int i = 1; i <= n; i++) data[i] = v[i - 1];
for (int i = 1; i <= n; i++) {
int j = i + (i & -i);
if (j <= n) data[j] += data[i];
}
}
void apply(int k, const T &x) {
for (++k; k <= n; k += k & -k) data[k] += x;
}
T prod(int r) const {
T ret = T();
for (; r > 0; r -= r & -r) ret += data[r];
return ret;
}
T prod(int l, int r) const { return prod(r) - prod(l); }
int lower_bound(T x) const {
int i = 0;
for (int k = 1 << (__lg(n) + 1); k > 0; k >>= 1) {
if (i + k <= n && data[i + k] < x) {
x -= data[i + k];
i += k;
}
}
return i;
}
int upper_bound(T x) const {
int i = 0;
for (int k = 1 << (__lg(n) + 1); k > 0; k >>= 1) {
if (i + k <= n && data[i + k] <= x) {
x -= data[i + k];
i += k;
}
}
return i;
}
};
static int xorshift(int n) {
static uint32_t x = 123456789;
static uint32_t y = 362436069;
static uint32_t z = 521288629;
static uint32_t w = 88675123;
uint32_t t;
t = x ^ (x << 11);
x = y;
y = z;
z = w;
return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8))) % n;
}
constexpr bool MULTI_TESTCASE = false;
void solve() {
int n, l, r;
cin >> n >> l >> r;
int ans = 0;
REP (i, n) {
int x, y;
cin >> x >> y;
if (x <= l && r <= y) ans++;
}
cout << ans << endl;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int t = 1;
if (MULTI_TESTCASE) cin >> t;
while (t--) {
solve();
}
}
Submission Info
| Submission Time |
|
| Task |
A - Streamer Takahashi |
| User |
gazelle |
| Language |
C++ 23 (gcc 12.2) |
| Score |
100 |
| Code Size |
14357 Byte |
| Status |
AC |
| Exec Time |
59 ms |
| Memory |
159316 KiB |
Compile Error
Main.cpp:462:12: warning: ‘int xorshift(int)’ defined but not used [-Wunused-function]
462 | static int xorshift(int n) {
| ^~~~~~~~
Judge Result
| Set Name |
Sample |
All |
| Score / Max Score |
0 / 0 |
100 / 100 |
| Status |
|
|
| Set Name |
Test Cases |
| Sample |
00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt |
| All |
00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_test_00.txt, 01_test_01.txt, 01_test_02.txt, 01_test_03.txt, 01_test_04.txt, 01_test_05.txt, 01_test_06.txt, 01_test_07.txt, 01_test_08.txt, 01_test_09.txt |
| Case Name |
Status |
Exec Time |
Memory |
| 00_sample_00.txt |
AC |
58 ms |
159308 KiB |
| 00_sample_01.txt |
AC |
59 ms |
159152 KiB |
| 00_sample_02.txt |
AC |
59 ms |
159212 KiB |
| 01_test_00.txt |
AC |
59 ms |
159308 KiB |
| 01_test_01.txt |
AC |
59 ms |
159244 KiB |
| 01_test_02.txt |
AC |
59 ms |
159140 KiB |
| 01_test_03.txt |
AC |
59 ms |
159204 KiB |
| 01_test_04.txt |
AC |
59 ms |
159248 KiB |
| 01_test_05.txt |
AC |
59 ms |
159316 KiB |
| 01_test_06.txt |
AC |
59 ms |
159152 KiB |
| 01_test_07.txt |
AC |
59 ms |
159160 KiB |
| 01_test_08.txt |
AC |
59 ms |
159152 KiB |
| 01_test_09.txt |
AC |
59 ms |
159224 KiB |