Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
99217 陈志轩 单词排序 C++ 通过 100 0 MS 256 KB 1017 2023-08-22 14:09:41

Tests(5/5):


#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; }


测评信息: