版本比较
题解:P3752 语言普查
正文
增加 8 行删除 8 行
42 行未改动4344454647474849505152535454555657585859606162636465656667676869697071727312 行未改动8687888990909192939494959697987 行未改动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)//简写 #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;//转小写 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 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,简化了 cin>>n; get_s;//getline 读入 s,简化了 lop(i,1,n,1){ //存字典 //存字典 string S; cin>>S; _erase(S); get_s; _erase(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 行未改动