Files
python/TangDou/CSP-J/AcWingTraining/T6/468_BruteForce_1.cpp
HuangHai 1f397eca87 'commit'
2025-08-30 18:35:01 +08:00

40 lines
1.1 KiB
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include <bits/stdc++.h>
using namespace std;
const int N = 40010;
int n, m;
int q[N];
// 40分
bool check(int a, int b, int c, int d) {
if (a >= b || b >= c || c >= d) return 0;
if ((b - a) != 2 * (d - c)) return 0;
if (3 * (b - a) >= (c - b)) return 0;
return 1;
}
int g[N][4];
int main() {
#ifndef ONLINE_JUDGE
freopen("468.in", "r", stdin);
#endif
cin >> n >> m;
// 魔法值都是不超过n的正整数,似乎没啥用
// m个魔法物品
for (int i = 1; i <= m; i++) cin >> q[i]; // 读入每个魔法物品的魔法值
for (int a = 1; a <= m; a++)
for (int b = 1; b <= m; b++)
for (int c = 1; c <= m; c++)
for (int d = 1; d <= m; d++)
if (check(q[a], q[b], q[c], q[d]))
g[a][0]++, g[b][1]++, g[c][2]++, g[d][3]++;
// a这个枚举到的数字出现了一次,它是做为a位置出现的
// 找到一组合法的a,b,c,d
// 输出结果
for (int i = 1; i <= m; i++)
printf("%d %d %d %d\n", g[i][0], g[i][1], g[i][2], g[i][3]);
return 0;
}