洛谷数据换行用了 \r 而不是 \n
\r
\n
记得把 getline(cin,x); 或 getline(cin,x,'\n'); 改成 getline(cin,x,'\r');
getline(cin,x);
getline(cin,x,'\n');
getline(cin,x,'\r');