Advertisement
7oSkaaa

Stickers on the wall (Easy)

Aug 18th, 2021
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.44 KB | None | 0 0
  1.   #include <bits/stdc++.h>
  2.   using namespace std;
  3.  
  4.   #define cin(vec) for(auto& i : vec) cin >> i
  5.   #define cin_2d(vec, n, m) for(int i = 0; i < n; i++) for(int j = 0; j < m && cin >> vec[i][j]; j++);
  6.   #define cout(vec) for(auto& i : vec) cout << i << " "; cout << "\n";
  7.   #define cout_map(mp) for(auto& [f, s] : mp) cout << f << "  " << s << "\n";
  8.   #define loop(a, b, c) for(int i = a ; i < (b); i += c)
  9.   #define Ceil(n, m) ((n / m) + (n % m ? 1 : 0))
  10.   #define all(vec) vec.begin(),vec.end()
  11.   #define rall(vec) vec.rbegin(),vec.rend()
  12.   #define sz size()
  13.   #define fi first
  14.   #define se second
  15.   #define Pair pair <int,int>
  16.   #define ll long long
  17.   #define ull unsigned long long
  18.   #define Mod  1000'000'007
  19.   #define INF 2000'000'000
  20.   #define PI 3.14159265359
  21.  
  22.   void Code_Crush(){
  23.     ios_base::sync_with_stdio(false);   cin.tie(nullptr);   cout.tie(nullptr);
  24.     #ifndef ONLINE_JUDGE
  25.       freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
  26.     #endif
  27.   }
  28.  
  29.   int main(){
  30.     Code_Crush();
  31.     int n, m, q;                     cin >> n >> m >> q;
  32.     vector <ll> points(n + 2);
  33.     while(q--){
  34.       int x1, x2;            cin >> x1 >> x2;
  35.       points[min(x1, x2)]++, points[max(x1, x2) + 1]--;
  36.     }
  37.     for(int i = 1; i <= n; i++){
  38.       points[i] += points[i - 1];
  39.     }
  40.     ll count = 0;
  41.     for(int i = 1; i <= n; i++){
  42.         count += !points[i];
  43.     }
  44.     cout << count;
  45.     return 0;
  46.   }  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement