为什么1000000000不超时??

P1640 [SCOI2010] 连续攻击游戏

```cpp #include<bits/stdc++.h> using namespace std; struct edge{ int to,next; }e[2000010]; int head[10010],cnt=0,p[1000010]; void add_edge(int s,int t){ e[++cnt].next=head[s];e[cnt].to=t;head[s]=cnt; } bool vis[1000010]; bool dfs(int s){ for(int i=head[s];i;i=e[i].next){ if(!vis[e[i].to]){ vis[e[i].to]=1; if(!p[e[i].to]||dfs(p[e[i].to])){ p[e[i].to]=s; return 1; } } } } int main(){ int n; cin>>n; for(int i=1;i<=n;++i){ int a,b; cin>>a>>b; add_edge(a,i); add_edge(b,i); } int ans=0; for(int i=1;i<=10000;++i){ memset(vis,0,sizeof(vis)); if(dfs(i)){ ++ans; } else break; } cout<<ans; return 0; } ```
by LonelinessMan @ 2018-11-16 20:13:28


意思是说你想超时?
by 三条小鱼 @ 2018-11-16 20:19:18


因为你只dfs10000次,后面没走几个点
by 1oclock @ 2018-11-16 20:21:14


但是有数据ans达到了10000。。。。
by LonelinessMan @ 2018-11-16 20:24:38


我的意思memset这么快的吗
by LonelinessMan @ 2018-11-16 20:24:57


@[LonelinessMan](/space/show?uid=109418) ~~废话~~
by 三条小鱼 @ 2018-11-16 20:26:29


@[三条小鱼](/space/show?uid=128420) - -
by LonelinessMan @ 2018-11-16 20:27:30


|