版本比较
题解:P3752 语言普查
正文
增加 8 行删除 8 行
42 行未改动4344454647484950515253545556575859606162636465666768697071727312 行未改动868788899091929394959697987 行未改动42 行未改动#define lop(x,l,r,c)\for(LL x=l;((r)-(x))*(c)>=0;x+=(c))//究极 lop#define the return#define AK_IOI std#define get_s getline(cin,s)//简写using namespace AK_IOI;const LL N=1e6+6;LL T,n,m,q,k,x,idx;string s;map<string,string> mp;// mp 存词语对应的语言void f(string &g){ LL len=g.size();lop(i,0,len-1,1) if(g[i]>='A'&&g[i]<='Z') g[i]+=32;//转小写}bool tr(char ch){if(ch==' '||ch=='.'||ch==','||ch=='?'||ch=='!'||ch==';'||ch=='('||ch==')')the true;//判断是否为分隔符the false;}void _erase(string &S){//删除 '\r' 这种讨厌的东西 而且全部字符串都要!!!S.erase(remove(S.begin(),S.end(),char(13)),S.end());}int main(){ cin.tie(0)->sync_with_stdio(0);cout.tie(0);cin>>n; get_s;//getline 读入 s,简化了lop(i,1,n,1){//存字典string S;cin>>S; _erase(S); get_s; _erase(s);LL len=s.size()-1,last=1;//last 记录上一个单词结尾lop(i,1,len,1){if(tr(s[i])){//分隔符,将前面一段拆出得到单词string h=s.substr(last,i-last); f(h); _erase(h);12 行未改动if(tr(s[i])){string h=s.substr(last,i-last); f(h); _erase(h);if(mp[h]!=""){cout<<mp[h]<<"\n"; break;//找到语言了}last=i+1;}}}return 0;}```7 行未改动42 行未改动4344454647484950515253545556575859606162636465666768697071727312 行未改动868788899091929394959697987 行未改动42 行未改动#define lop(x,l,r,c)\for(LL x=l;((r)-(x))*(c)>=0;x+=(c))//究极 lop#define the return#define AK_IOI std#define get_s getline(cin,s)//简写using namespace AK_IOI;const LL N=1e6+6;LL T,n,m,q,k,x,idx;string s;map<string,string> mp;// mp 存词语对应的语言void f(string &g){ LL len=g.size();lop(i,0,len-1,1) if(g[i]>='A'&&g[i]<='Z') g[i]+=32;//转小写}bool tr(char ch){if(ch==' '||ch=='.'||ch==','||ch=='?'||ch=='!'||ch==';'||ch=='('||ch==')')the true;//判断是否为分隔符the false;}void _erase(string &S){//删除 '\r' 这种讨厌的东西 而且全部字符串都要!!!S.erase(remove(S.begin(),S.end(),char(13)),S.end());}int main(){ cin.tie(0)->sync_with_stdio(0);cout.tie(0);cin>>n; get_s;//getline 读入 s,简化了lop(i,1,n,1){//存字典string S;cin>>S; _erase(S); get_s; _erase(s);LL len=s.size()-1,last=1;//last 记录上一个单词结尾lop(i,1,len,1){if(tr(s[i])){//分隔符,将前面一段拆出得到单词string h=s.substr(last,i-last); f(h); _erase(h);12 行未改动if(tr(s[i])){string h=s.substr(last,i-last); f(h); _erase(h);if(mp[h]!=""){cout<<mp[h]<<"\n"; break;//找到语言了}last=i+1;}}}return 0;}```7 行未改动