Guest User

Untitled

a guest
Feb 13th, 2021
460
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.94 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define pi pair<int,int>
  5. #define pll pair<ll,ll>
  6. #define ld  long double
  7.  
  8. const int INF = 1e9 + 7;
  9.  
  10. map<int , bool> visited;
  11. void dfs(int start , int curr ,set<int> &possible){
  12.     if(curr < 0) return;
  13.     visited[start] = true;
  14.     possible.insert(start);
  15.     if(!visited.count(-start)){
  16.         dfs(-start , curr - 1 , possible);
  17.     }
  18.     if(!visited.count(start - 1)){
  19.         dfs(start - 1, curr - 2 , possible);
  20.     }
  21. }
  22. void solve(){
  23.     set<int> possible;
  24.     ll B , C;
  25.     cin >> B >> C;
  26.     dfs(B , C , possible);
  27.     cout << int(possible.size()) << endl;
  28.     // cout << "the possible values " << endl;
  29.     // for(auto t : possible)
  30.     //  cout << t <<  " ";
  31.     // cout << endl;
  32. }
  33.  
  34. int main(){
  35.     ios :: sync_with_stdio(false);
  36.     cin.tie(nullptr);
  37.     cout.tie(nullptr);
  38.     int tt = 1;
  39.    
  40.     for(int tc = 1; tc <= tt; tc++){
  41.         // cout << "Case #" << tc << ": ";
  42.         solve();
  43.     }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment