59 lines
1.5 KiB
C++
59 lines
1.5 KiB
C++
#include <bits/stdc++.h>
|
||
using namespace std;
|
||
|
||
typedef long long LL;
|
||
const int N = 15010, M = 40010;
|
||
int n, m;
|
||
int x[M];
|
||
LL cnt[N];
|
||
LL num[N][4];
|
||
// 65分 4层循环,按桶的思路枚举每个魔法值,暴力枚举a,b,c,d
|
||
LL read() {
|
||
LL x = 0, f = 1;
|
||
char ch = getchar();
|
||
while (ch < '0' || ch > '9') {
|
||
if (ch == '-') f = -1;
|
||
ch = getchar();
|
||
}
|
||
while (ch >= '0' && ch <= '9') {
|
||
x = (x << 3) + (x << 1) + (ch ^ 48);
|
||
ch = getchar();
|
||
}
|
||
return x * f;
|
||
}
|
||
|
||
int main() {
|
||
#ifndef ONLINE_JUDGE
|
||
freopen("468.in", "r", stdin);
|
||
#endif
|
||
n = read(), m = read();
|
||
for (int i = 1; i <= m; i++) {
|
||
x[i] = read();
|
||
cnt[x[i]]++;
|
||
}
|
||
|
||
for (int a = 1; a <= n; a++)
|
||
for (int b = a + 1; b <= n; b++)
|
||
for (int c = b + 1; c <= n; c++)
|
||
for (int d = c + 1; d <= n; d++) {
|
||
if ((b - a) & 1 || 3 * (b - a) >= (c - b)) continue;
|
||
if ((b - a) != 2 * (d - c)) continue;
|
||
LL ans = cnt[a] * cnt[b] * cnt[c] * cnt[d];
|
||
num[a][0] += ans;
|
||
num[b][1] += ans;
|
||
num[c][2] += ans;
|
||
num[d][3] += ans;
|
||
}
|
||
for (int i = 1; i <= n; i++)
|
||
for (int j = 0; j < 4; j++)
|
||
num[i][j] /= cnt[i] ? cnt[i] : 1;
|
||
|
||
for (int i = 1; i <= m; i++) {
|
||
for (int j = 0; j < 4; j++)
|
||
|
||
printf("%lld ", num[x[i]][j]);
|
||
puts("");
|
||
}
|
||
return 0;
|
||
}
|