File tree Expand file tree Collapse file tree 2 files changed +61
-0
lines changed
Codeforces/After Placement Expand file tree Collapse file tree 2 files changed +61
-0
lines changed Original file line number Diff line number Diff line change 1+ /*
2+ written by Pankaj Kumar.
3+ country:-INDIA
4+ */
5+ #include < bits/stdc++.h>
6+ using namespace std ;
7+ typedef long long ll;
8+
9+ int solve ()
10+ {
11+ int a, b;
12+ cin >> a >> b;
13+ a = abs (a);
14+ b = abs (b);
15+ int ans = 2 * min (a, b);
16+ if (a != b)
17+ {
18+ ans += 2 * (abs (b - a)) - 1 ;
19+ }
20+ cout << ans << endl;
21+
22+ return 0 ;
23+ }
24+ int main ()
25+ {
26+ int testCase = 1 ;
27+ cin >> testCase;
28+ while (testCase--)
29+ {
30+ solve ();
31+ }
32+ return 0 ;
33+ }
Original file line number Diff line number Diff line change 1+ /*
2+ written by Pankaj Kumar.
3+ country:-INDIA
4+ */
5+ typedef long long ll ;
6+ const ll INF=1e18 ;
7+ const ll mod1=1e9 +7 ;
8+ const ll mod2=998244353 ;
9+ // Add main code here
10+
11+ class Solution
12+ {
13+ public:
14+ long long beautifulSubarrays (vector<int > &nums)
15+ {
16+ map<int , int > seen;
17+ seen[0 ]++;
18+ long long ans = 0 ;
19+ int sum = 0 ;
20+ for (int v : nums)
21+ {
22+ sum ^= v;
23+ ans += seen[sum];
24+ seen[sum]++;
25+ }
26+ return ans;
27+ }
28+ };
You can’t perform that action at this time.
0 commit comments