记录编号 462995 评测结果 AAAAAAAAAA
题目名称 字符串子串 最终得分 100
用户昵称 GravatarHeHe 是否通过 通过
代码语言 C++ 运行时间 0.003 s
提交时间 2017-10-23 18:48:38 内存使用 0.57 MiB
显示代码纯文本
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;

inline char getc(void) { 
    static char buf[1 << 18], *fs, *ft;
    return (fs == ft && (ft = (fs = buf) + fread(buf, 1, 1 << 18, stdin)), fs == ft) ? EOF : *fs++;
}

inline int read(void) { 
    char tmp = getc();
    int res = 0;
    while(!isdigit(tmp)) tmp = getc();
    while(isdigit(tmp))
        res = ((res + (res << 2)) << 1) + (tmp ^ 0x30),
        tmp = getc();
    return res;
}

inline int read(char *s) { 
    char *p = s;
    while(!isgraph(*p = getc()));
    while(isgraph(*(++p) = getc()));
    *p = '\0';
    return p - s;
}

inline bool cmp(const string &a, const string &b);

vector<string> str;
char tmp[110];
int N;

int main() { 
#ifndef LOCAL
    freopen("substring.in", "r", stdin);
    freopen("substring.out", "w", stdout);
#endif
    N = read();
    for(int i = 0; i < N; ++i) { 
        read(tmp);
        str.push_back(string(tmp));
    }
    sort(str.begin(), str.end(), cmp);
    for(int i = 0; i < N; ++i)
        cout << str[i];
    return 0;
}

inline bool cmp(const string &a, const string &b) { 
    return a + b < b + a;
}