-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprob_00400.cpp
53 lines (52 loc) · 1.03 KB
/
prob_00400.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
43
44
45
46
47
48
49
50
51
52
53
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <map>
#include <cstring>
#include <vector>
#include <stack>
#include <queue>
#include <stdlib.h>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#define repf(i,b,n) for(i=b;i<n;i++)
#define repb(i,b,n) for(i=n;i>=b;i--)
#define si(a) scanf("%d",&a)
#define sii(a,b) scanf("%d%d",&a,&b)
#define gc getchar_unlocked
using namespace std;
int main(){
int n,i,j,k;
vector<string> vect;
string str;
int max_len;
while(scanf("%d\n",&n)!=EOF){
max_len=0;
repf(i,0,n){
getline(cin,str);
vect.push_back(str);
}
sort(vect.begin(),vect.end());
for(vector<string>::iterator iter= vect.begin(), end= vect.end();
iter!= end; ++iter){
int len= iter->length();
if(max_len< len)
max_len= len;
}
int m=62/(max_len+2);
k=ceil(n/float(m));
repf(i,0,60) putchar('-');
putchar('\n');
repf(i,0,k){
for(j=i;j<n;j+=k){
if(j+k < n)
cout << setw(max_len+2);
cout <<left << vect[j] ;
}
puts("");
}
vect.clear();
}
}