public class Solution {
public int[] CountOfPairs(int n, int x, int y) {
int tmp1 = x;
int tmp2 = y;
x = Math.Min(tmp1, tmp2);
y = Math.Max(tmp1, tmp2);
x--;y--;
int[] array = new int[n];
for(int i = 0;i<n;i++) {
for(int j = i + 1; j< n;j++) {
int step = j - i;
// out side
if(j <= x) {
array[step - 1]+=2;
continue;
}
if(i>=y) {
array[step - 1]+=2;
continue;
}
// inside
if(i>=x && j <=y) {
step = Math.Min(j - i, i - x + y - j + 1);
array[step - 1] +=2;
continue;
}
if(i <= x && j >= y) {
step = Math.Min(j - i, x - i + j - y + 1);
array[step - 1] +=2;
continue;
}
if(i <= x && j <=y) {
step = x - i + Math.Min(j - x, 1 + y - j);
array[step - 1] += 2;
continue;
}
step = j - y + Math.Min(y - i, i - x + 1);
array[step - 1] += 2;
}
}
return array;
}
}