Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define ll long long
- #define pi pair<int,int>
- #define pll pair<ll,ll>
- #define ld long double
- const int INF = 1e9 + 7;
- map<int , bool> visited;
- void dfs(int start , int curr ,set<int> &possible){
- if(curr < 0) return;
- visited[start] = true;
- possible.insert(start);
- if(!visited.count(-start)){
- dfs(-start , curr - 1 , possible);
- }
- if(!visited.count(start - 1)){
- dfs(start - 1, curr - 2 , possible);
- }
- }
- void solve(){
- set<int> possible;
- ll B , C;
- cin >> B >> C;
- dfs(B , C , possible);
- cout << int(possible.size()) << endl;
- // cout << "the possible values " << endl;
- // for(auto t : possible)
- // cout << t << " ";
- // cout << endl;
- }
- int main(){
- ios :: sync_with_stdio(false);
- cin.tie(nullptr);
- cout.tie(nullptr);
- int tt = 1;
- for(int tc = 1; tc <= tt; tc++){
- // cout << "Case #" << tc << ": ";
- solve();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment