Files
python/GESP/ShiTangPaiDui.cpp

24 lines
484 B
C++
Raw Permalink Normal View History

2025-08-30 18:35:01 +08:00
#include <bits/stdc++.h>
using namespace std;
int n, m; // n个同学m个窗口
const int N = 100000 + 10;
vector<int> a[N];
int main() {
cin >> n >> m;
for (int i = 1; i <= n; i++) {
int x;
cin >> x; // 表示i号同学需要加入x号窗口
a[x].push_back(i);
}
for (int i = 1; i <= m; i++) {
cout << a[i].size() << " ";
for (int j = 0; j < a[i].size(); j++)
cout << a[i][j] << " ";
cout << endl;
}
return 0;
}