版本比较
10.5模拟赛
正文
增加 107 行删除 0 行
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108# T1::::info[题目]{open}[U735287 数字单词](https://www.luogu.com.cn/problem/U735287)::::::::error[WA代码]```cpp line-numbers#include<bits/stdc++.h>using namespace std;const int N=1e5+10;int cnt1,cnt2;string a[N],b[N];int main(){// freopen(".in","r",stdin);// freopen(".out","w",stdout); ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); string s; cin>>s; string s1=""; bool flag=0; for(int i=0;i<s.size();i++){ if(s[i]!=';'&&s[i]!=','){ if(s[i]>'9'||s[i]<'0'||(s1==""&&s[i]=='0')) flag=1; s1+=s[i]; } else{ if(flag==1||s1=="") b[++cnt2]=s1; else a[++cnt1]=s1; s1=""; } } if(flag==1||s1=="") b[++cnt2]=s1; else a[++cnt1]=s1; s1=""; if(cnt1==0) cout<<"-\n"; else{ cout<<'"'; for(int i=1;i<=cnt1;i++){ if(i>1) cout<<','; cout<<a[i]; } cout<<'"'<<'\n'; } if(cnt2==0) cout<<"-\n"; else{ cout<<'"'; for(int i=1;i<=cnt2;i++){ if(i>1) cout<<','; cout<<b[i]; } cout<<'"'<<'\n'; } return 0;} ```::::::::warning[错因]"0"也算数字串,flag没有更新::::# T2::::info[题目]{open}[U735302 旅行](https://www.luogu.com.cn/problem/U735302)::::::::error[WA代码]``` cpp line-numbers#include<bits/stdc++.h>using namespace std;const int N=2010,inf=0x3f3f3f3f;int d[N][N];int main(){// freopen(".in","r",stdin);// freopen(".out","w",stdout); ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n,m; cin>>n>>m; for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) d[i][j]=0; for(int i=1;i<=n;i++) d[i][i]=1; for(int i=1;i<=m;i++){ int x,y; cin>>x>>y; d[x][y]=1; } for(int k=1;k<=n;k++){ for(int i=1;i<=n;i++){ for(int j=1;j<=n;j++){ if(d[i][k]==1&&d[k][j]==1) d[i][j]=1; } } } int cnt=0; for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) cnt+=d[i][j]; cout<<cnt<<'\n'; return 0;} ```::::::::warning[错因]本来dfs和bfs都能过,结果$O(n^3)$的Floyd给我整$\textcolor{blue}{TLE}$了!!::::