比赛 |
4043级NOIP2022欢乐赛8th |
评测结果 |
AAAAAEEEEEEEEEEEEEEE |
题目名称 |
Dance Mooves |
最终得分 |
25 |
用户昵称 |
该账号已注销 |
运行时间 |
2.806 s |
代码语言 |
C++ |
内存使用 |
0.00 MiB |
提交时间 |
2022-11-21 21:28:52 |
显示代码纯文本
#include <bits/stdc++.h>
using namespace std;
int n, a[2010], b[2010], k;
int p[2010];
bool v[2010][2010] = {0};
int c[2010];
int main() {
freopen("dance.in", "r", stdin);
freopen("dance.out", "w", stdout);
cin >> n >> k;
for (int i = 1; i <= k; i++) {
cin >> a[i] >> b[i];
p[a[i]] = a[i];
p[b[i]] = b[i];
v[a[i]][a[i]] = 1;
v[b[i]][b[i]] = 1;
}
for (int i = 1; i <= n; i++)
c[i]++;
for (int l = 0; l <= k * k; l++) {
int i = l % k + 1;
swap(p[a[i]], p[b[i]]);
if (v[a[i]][p[a[i]]] == 0) {
v[a[i]][p[a[i]]] = 1;
c[p[a[i]]]++;
}
if (v[b[i]][p[b[i]]] == 0) {
v[b[i]][p[b[i]]] = 1;
c[p[b[i]]]++;
}
}
for (int i = 1; i <= n; i++) {
cout << c[i] << endl;
}
return 0;
}