結果
問題 | No.1557 Binary Variable |
ユーザー | nanophoto12 |
提出日時 | 2021-06-25 22:41:42 |
言語 | C++17 (gcc 13.2.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 503 ms / 2,000 ms |
コード長 | 3,218 bytes |
コンパイル時間 | 4,650 ms |
コンパイル使用メモリ | 268,756 KB |
実行使用メモリ | 47,192 KB |
最終ジャッジ日時 | 2023-09-07 14:48:02 |
合計ジャッジ時間 | 17,759 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 234 ms
25,280 KB |
testcase_01 | AC | 218 ms
18,068 KB |
testcase_02 | AC | 1 ms
4,380 KB |
testcase_03 | AC | 2 ms
4,384 KB |
testcase_04 | AC | 111 ms
8,864 KB |
testcase_05 | AC | 113 ms
9,996 KB |
testcase_06 | AC | 102 ms
8,156 KB |
testcase_07 | AC | 109 ms
9,088 KB |
testcase_08 | AC | 136 ms
10,056 KB |
testcase_09 | AC | 140 ms
9,008 KB |
testcase_10 | AC | 205 ms
12,136 KB |
testcase_11 | AC | 206 ms
12,388 KB |
testcase_12 | AC | 133 ms
10,112 KB |
testcase_13 | AC | 213 ms
12,752 KB |
testcase_14 | AC | 432 ms
39,356 KB |
testcase_15 | AC | 232 ms
13,728 KB |
testcase_16 | AC | 420 ms
36,676 KB |
testcase_17 | AC | 385 ms
29,344 KB |
testcase_18 | AC | 346 ms
24,764 KB |
testcase_19 | AC | 476 ms
46,180 KB |
testcase_20 | AC | 471 ms
45,016 KB |
testcase_21 | AC | 475 ms
44,900 KB |
testcase_22 | AC | 482 ms
45,852 KB |
testcase_23 | AC | 476 ms
44,684 KB |
testcase_24 | AC | 478 ms
46,612 KB |
testcase_25 | AC | 483 ms
46,528 KB |
testcase_26 | AC | 485 ms
46,808 KB |
testcase_27 | AC | 490 ms
47,032 KB |
testcase_28 | AC | 494 ms
47,096 KB |
testcase_29 | AC | 503 ms
47,156 KB |
testcase_30 | AC | 485 ms
47,192 KB |
testcase_31 | AC | 493 ms
47,192 KB |
testcase_32 | AC | 489 ms
47,144 KB |
testcase_33 | AC | 457 ms
43,964 KB |
testcase_34 | AC | 2 ms
4,376 KB |
testcase_35 | AC | 2 ms
4,380 KB |
testcase_36 | AC | 2 ms
4,376 KB |
ソースコード
#include <bits/stdc++.h> #define M_PI 3.14159265358979323846 // pi using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair<ll, ll> P; typedef tuple<ll, ll, ll> t3; typedef tuple<ll, ll, ll, ll> t4; #define rep(a,n) for(ll a = 0;a < n;a++) #define repi(a,n) for(ll a = n - 1;a >= 0;a--) template<typename T> void chmax(T& reference, T value) { reference = max(reference, value); } template<typename T> void chmaxmap(map<T, T>& m, T key, T value) { if (m.count(key)) { chmax(m[key], value); } else { m[key] = value; } } template<typename T> void chmin(T& reference, T value) { reference = min(reference, value); } #include <atcoder/all> using namespace atcoder; typedef modint1000000007 mint; constexpr ll mod = 1000000007; constexpr ll mpow(ll x, ll n) { ll ans = 1; x %= mod; while (n != 0) { if (n & 1) ans = ans * x % mod; x = x * x % mod; n = n >> 1; } return ans; } class Primes { private: vector<int> Prime_Number; vector<bool> is_prime_; public: Primes(int N) { is_prime_.resize(N + 1, true); is_prime_[0] = is_prime_[1] = false; for (int i = 0; i < N + 1; i++) { if (is_prime_[i]) { Prime_Number.push_back(i); for (int j = 2 * i; j <= N; j += i) is_prime_[j] = false; } } } int operator[](int i) { return Prime_Number[i]; } int size() { return Prime_Number.size(); } int back() { return Prime_Number.back(); } bool isPrime(int q) { return is_prime_[q]; } }; class SDivisor { public: vector<ll> F; SDivisor(ll N) { for (ll i = 1; i * i <= N; i++) { if (N % i == 0) { F.push_back(i); if (i * i != N) F.push_back(N / i); } } sort(begin(F), end(F)); } int size() { return F.size(); } ll operator[](int k) { return F[k]; } const vector<ll>& factors() { return F; } }; class Divisor { private: vector<ll> F; vector<pair<ll, ll>> pfactorize; public: Divisor(ll N) { for (ll i = 1; i * i <= N; i++) { if (N % i == 0) { F.push_back(i); if (i * i != N) F.push_back(N / i); } } sort(begin(F), end(F)); Primes p((ll)sqrt(N) + 1); for (int i = 0; i < p.size(); i++) { pfactorize.emplace_back(p[i], 0); while (N % p[i] == 0) { N /= p[i]; pfactorize.back().second++; } if (pfactorize.back().second == 0) pfactorize.pop_back(); } if (N > 1) pfactorize.emplace_back(N, 1); } int size() { return F.size(); } const vector<pair<ll, ll>>& pfac() { return pfactorize; } ll operator[](int k) { return F[k]; } const vector<ll>& factors() { return F; } }; int main() { ll n, m; cin >> n >> m; map<ll, vector<ll>> es; vector<bool> visit(m + 10, false); rep(i, m) { ll l, r; cin >> l >> r; es[l].push_back(- i - 1); es[r].push_back(i + 1); } vector<ll> ids; ll ans = 0; for (auto& x : es) { ll key = x.first; vector<ll> any; for (auto y : x.second) { ll id = abs(y); int enter = y < 0; if (enter) { if (visit[id]) continue; ids.push_back(id); } else { if (visit[id]) continue; any.push_back(id); } } if (any.size()) { ans++; for (auto a : ids) visit[a] = 1; ids.clear(); } } cout << n - ans << endl; return 0; }