数据范围超过 1e5 要用 scanf 和 printf
去替换 cin 和 cout
时间消耗会降低很多。
如果 TL 的话可以换一下 scanf / printf
试一试
string 不能用 scanf 读入,但是可以用 char[] 读入去进行代替
读入 int 需要加上 & 符号,char[] 则不能加
char u_id[10];
int p_id, p_grade;
scanf("%s %d %d", u_id, &p_id, &p_grade);
用 printf 输出 string 时是不能直接输出的,需要调用 c.str()
函数
string str = "string";
printf("%s", str.c_str());
stringstream 读一行类似于单词的东西进来
vector<string> keyword;
string line;
getline(cin, line);
// stringstream 一定要学会怎么用
stringstream ssin(line);
string word;
while (ssin >> word)
keyword.insert(word);