思路很简单,字符串匹配,顺序扫一遍,o(n)的算法,居然TLE~~~~
原因居然是strlen!!!!
难道执行100000 strlen也算超时!!!! 受教了!!!
TLE代码如下:
#include#include #include #include #include #include using namespace std; #define N 500005 #define eps 1e-8 char words[N]; char key[N]; int solve(){ int i=0; int len=strlen(key); for(int j=0;j
修改strlen 之后,居然就过了~~~~~~
for(int i=0;i
看来,以后用库函数,要慎重!!!