提交时间:2023-08-22 14:09:41
运行 ID: 99217
#include<bits/stdc++.h> //#define int long long using namespace std; namespace Fast{ inline int fr(){ register int x = 0,f = 1; static char c = getchar(); while (c < '0' || c > '9'){ if (c == '-'){ f = -1; } c = getchar(); } while (c >= '0' && c <= '9'){ x = (x << 1) + (x << 3) + (c ^ 48); c = getchar(); } return x * f; } inline void fw(int x){ if (x < 0){ x = -x; putchar('-'); } if (x > 9){ fw(x / 10); } putchar(x % 10 + 48); } } using namespace Fast; vector <string> vec; bool cmp(string a,string b){ return a < b; } signed main(){ string s,ret = ""; getline(cin,s); int sum = 0; for (int i = 0;i < s.size();i++){ if (s[i] == ',' || s[i] == '.' || s[i] == ' ' || s[i] == '!'){ vec.push_back(ret); ret = ""; sum++; continue; } ret += s[i]; } sort(vec.begin(),vec.end(),cmp); fw(sum); puts(""); for (int i = 0;i < vec.size();i++){ cout<<vec[i]<<'\n'; } return 0; }