-
Notifications
You must be signed in to change notification settings - Fork 3
/
11100.cpp
42 lines (36 loc) · 808 Bytes
/
11100.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
using namespace std;
int n, bags[10001];
bool taken[10001];
vector<vector<int> > ans;
int main() {
int t = 0;
while (cin >> n and n) {
if (t++) cout << endl;
for (int i = 0; i < n; i++) cin >> bags[i];
sort(bags, bags + n);
bags[n] = -1;
memset(taken, 0, sizeof(taken));
ans.clear();
int numSame = 1, cur = 1;
for (int i = 1; i <= n; i++) {
if (bags[i] == bags[i - 1]) cur++;
else {
numSame = max(cur, numSame);
cur = 1;
}
}
cout << numSame << endl;
for (int i = 0; i < numSame; i++) {
for (int j = i; j < n; j += numSame) {
if (i != j) cout << ' ';
cout << bags[j];
}
cout << endl;
}
}
return 0;
}