結果
| 問題 | No.1557 Binary Variable | 
| コンテスト | |
| ユーザー |  miscalc | 
| 提出日時 | 2021-06-25 21:53:19 | 
| 言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) | 
| 結果 | 
                                RE
                                 
                             | 
| 実行時間 | - | 
| コード長 | 1,195 bytes | 
| コンパイル時間 | 6,167 ms | 
| コンパイル使用メモリ | 261,464 KB | 
| 最終ジャッジ日時 | 2025-01-22 12:12:36 | 
| ジャッジサーバーID (参考情報) | judge4 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | RE * 3 | 
| other | AC * 3 RE * 31 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pll = pair<ll, ll>;
using tlll = tuple<ll, ll, ll>;
//constexpr ll MOD = 1e9 + 7;
constexpr ll MOD = 998244353;
//constexpr ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
constexpr ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
#define FINALANS(A) do {cout << (A) << '\n'; exit(0);} while (false)
int main()
{
  ll N, M;
  cin >> N >> M;
  set<pll> RL;
  for (ll i = 0; i < M; i++)
  {
    ll l, r;
    cin >> l >> r;
    RL.emplace(make_pair(r, l));
  }
  /*
  for (auto rl : RL)
  {
    cerr << rl.first << " " << rl.second << endl;
  }
  //*/
  ll ans = 0;
  while (!RL.empty())
  {
    pll rl = *RL.begin();
    ll r = rl.first, l = rl.second;
    for (auto r0l0 : RL)
    {
      ll r0 = r0l0.first, l0 = r0l0.second;
      if (l0 <= r && r <= r0)
        RL.erase(r0l0);
    }
    ans++;
    //cerr << r << " " << l << " " << RL.size() << endl;
  }
  cout << N - ans << endl;
}
            
            
            
        