24 lines
484 B
C++
24 lines
484 B
C++
|
|
#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;
|
|||
|
|
}
|