結果
問題 | No.1557 Binary Variable |
ユーザー | nanophoto12 |
提出日時 | 2021-06-25 22:39:22 |
言語 | C++17 (gcc 13.2.0 + boost 1.83.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 3,278 bytes |
コンパイル時間 | 4,303 ms |
コンパイル使用メモリ | 270,948 KB |
実行使用メモリ | 147,092 KB |
最終ジャッジ日時 | 2023-09-07 14:46:42 |
合計ジャッジ時間 | 19,904 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 274 ms
147,092 KB |
testcase_01 | AC | 253 ms
140,128 KB |
testcase_02 | AC | 31 ms
125,376 KB |
testcase_03 | AC | 2 ms
4,380 KB |
testcase_04 | RE | - |
testcase_05 | RE | - |
testcase_06 | RE | - |
testcase_07 | RE | - |
testcase_08 | RE | - |
testcase_09 | RE | - |
testcase_10 | RE | - |
testcase_11 | RE | - |
testcase_12 | RE | - |
testcase_13 | RE | - |
testcase_14 | AC | 459 ms
39,364 KB |
testcase_15 | RE | - |
testcase_16 | AC | 442 ms
36,656 KB |
testcase_17 | AC | 398 ms
29,392 KB |
testcase_18 | AC | 356 ms
25,092 KB |
testcase_19 | AC | 479 ms
46,964 KB |
testcase_20 | AC | 482 ms
45,064 KB |
testcase_21 | AC | 479 ms
45,080 KB |
testcase_22 | AC | 493 ms
46,508 KB |
testcase_23 | AC | 465 ms
44,804 KB |
testcase_24 | AC | 488 ms
48,340 KB |
testcase_25 | AC | 486 ms
47,716 KB |
testcase_26 | AC | 485 ms
49,232 KB |
testcase_27 | AC | 472 ms
50,504 KB |
testcase_28 | AC | 495 ms
58,144 KB |
testcase_29 | AC | 510 ms
89,808 KB |
testcase_30 | AC | 507 ms
69,724 KB |
testcase_31 | AC | 515 ms
99,944 KB |
testcase_32 | AC | 500 ms
71,520 KB |
testcase_33 | AC | 460 ms
43,968 KB |
testcase_34 | AC | 2 ms
4,376 KB |
testcase_35 | AC | 1 ms
4,380 KB |
testcase_36 | AC | 1 ms
4,380 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(n + 10, false); rep(i, m) { ll l, r; cin >> l >> r; es[l].push_back(- i - 1); es[r].push_back(i + 1); } for (auto& x : es) sort(x.second.begin(), x.second.end()); 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; }