C++ Solution || beaten 100% of the submissions || Easily Understandable
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity: O(n)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(n)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\n#define ll long long\nclass Solution {\npublic:\n    vector<long long> countOfPairs(int n, int x, int y) {\n        vector<ll> ans(n+1,0);\n        if(x==y){\n            ans.pop_back();\n            for(int i=0;i<n;i++) ans[i] = 2*(n-i-1);\n            return ans;\n        }\n        if(x>y) swap(x,y);\n        for(int i=1;i<=n;i++){\n            if(i<=x){\n                ans[0]+=2;ans[n-y+x-i+1]-=2;\n                ans[x-i]+=2;ans[x-i+(y-x)/2]-=2;\n                ans[x-i+1]+=2;ans[x-i+1+(y-x-1)/2]-=2;\n            }else if(i>x && i<y){\n                if(i-x<=(y-x-1)/2){\n                    ans[i-x]+=2;ans[i-x+1+n-y]-=2;\n                }else{\n                    ans[y-i-1]+=2;ans[n-i]-=2;\n                }\n                if(i+(y-x)/2<y){\n                    ans[0]+=2;ans[(y-x+1)/2]-=2;\n                    ans[i-x+1]+=2;ans[(y-x)/2]-=2;\n                }else{\n                    ans[0]+=2;ans[y-i-1]-=2;\n                }\n            }else{\n                ans[0]+=2;ans[n-i]-=2;\n            }\n        }\n        for(int i=1;i<n;i++){\n            ans[i]+=ans[i-1];\n        }\n        ans.pop_back();\n        return ans;\n    }\n};\n```
['C++']