萌新真诚求助

P1042 [NOIP2003 普及组] 乒乓球

请问如何解决qwq
by D_M_ @ 2022-02-05 17:06:26


`10000010`数组开太大了
by _l_l_l_l_l_ @ 2022-02-05 17:09:07


@[WenZKbb](/user/522828) 删了两个0,不行
by D_M_ @ 2022-02-05 17:11:16


`for(ll i=1;a[i]!='E';i++){`改成` for(ll i=1;a[i-1]!='E';i++){`就不RE了(第i个还没有读入...) 但是会TLE
by _l_l_l_l_l_ @ 2022-02-05 17:17:16


[改后五个TLE,其余全RE](https://www.luogu.com.cn/record/68575089)
by D_M_ @ 2022-02-05 17:18:26


@[WenZKbb](/user/522828)
by D_M_ @ 2022-02-05 17:18:45


`while(~scanf("%s",str))`读入不确定的字符串可以这么写
by _l_l_l_l_l_ @ 2022-02-05 17:19:20


@[WenZKbb](/user/522828) 报错 ```cpp [Error] cannot pass objects of non-trivially-copyable type 'std::string {aka class std::basic_string<char>}' through '...' ```
by D_M_ @ 2022-02-05 17:22:17


报错是因为scanf读的是char数组 ```cpp #include <bits/stdc++.h> #define ll long long using namespace std; int jushu[10000010],w,l,n,cnt=0; char a[62505]; char str[30]; int main(){ // // for(ll i=1;a[i]!='E';i++){ // cin >> a[i]; // n++; // } while(~scanf("%s",str+1)){ int len=strlen(str+1); for(int i=1;i<=len;i++){ a[++cnt]=str[i]; } if(str[len]=='E')break; } n=cnt; for(int i=1;i<=n;i++){ for(int j=1;j<=n;j++){ if(a[j]=='W'){ w++; }else{ l++; } } if(w>=l+2&&w>=11){ cout << w << ":" << l << endl; } w=0; l=0; } for(ll i=1;i<=n;i++){ for(ll j=1;j<=n;i++){ if(a[j]=='W'){ w++; }else{ l++; } } if(w>=l+2&&w>=21){ cout << w << ":" << l << endl; } w=0; l=0; } return 0; } ``` 当然后面的程序还有问题
by _l_l_l_l_l_ @ 2022-02-05 17:26:39


@[WenZKbb](/user/522828) 没RE了,全TLE了
by D_M_ @ 2022-02-05 17:28:27


| 下一页