欧美三级国产三级日韩三级_亚洲熟妇丰满大屁股熟妇_欧美亚洲成人一区二区三区_国产精品久久久久久模特

Codeforces Round #387 (Div. 2) E. Comments (dfs) - 新聞資訊 - 云南小程序開(kāi)發(fā)|云南軟件開(kāi)發(fā)|云南網(wǎng)站建設(shè)-昆明葵宇信息科技有限公司

159-8711-8523

云南網(wǎng)建設(shè)/小程序開(kāi)發(fā)/軟件開(kāi)發(fā)

知識(shí)

不管是網(wǎng)站,軟件還是小程序,都要直接或間接能為您產(chǎn)生價(jià)值,我們?cè)谧非笃湟曈X(jué)表現(xiàn)的同時(shí),更側(cè)重于功能的便捷,營(yíng)銷的便利,運(yùn)營(yíng)的高效,讓網(wǎng)站成為營(yíng)銷工具,讓軟件能切實(shí)提升企業(yè)內(nèi)部管理水平和效率。優(yōu)秀的程序?yàn)楹笃谏?jí)提供便捷的支持!

您當(dāng)前位置>首頁(yè) » 新聞資訊 » 技術(shù)分享 >

Codeforces Round #387 (Div. 2) E. Comments (dfs)

發(fā)表時(shí)間:2020-10-18

發(fā)布人:葵宇科技

瀏覽次數(shù):65

Codeforces Round #387 (Div. 2) E. Comments (dfs)

思路:按樹(shù)的深度進(jìn)行 d f s dfs dfs即可。

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e6+5,M=2e4+5,inf=0x3f3f3f3f,mod=1e9+7;
#define mst(a,b) memset(a,b,sizeof a)
#define lx x<<1
#define rx x<<1|1
#define reg register
#define PII pair<int,int>
#define fi first
#define se second
#define pb push_back
#define il inline
#define ios ios::sync_with_stdio(0),cin.tie(0)
int mx;
string d[N];
bool dfs(int dep){
	string s;
	getline(cin,s,',');
	if(s=="") return false;
	d[dep]+=s+" ";
	getline(cin,s,',');
	int n=stoi(s);
	while(n--) dfs(dep+1);
	mx=max(mx,dep);	
	return true;
}
int main(){
	ios;
	while(dfs(1));
	cout<<mx<<'\n';
	for(int i=1;i<=mx;i++) cout<<d[i]<<'\n';
	return 0;
}

原來(lái)之前寫(xiě)的都是假的關(guān)閉流同步。
1.ios::sync_with_stdio(0) 這一步是取消 i o s t r e a m iostream iostream s t d i o stdio stdio的同步,避免把輸出的東西先存入緩沖區(qū)再輸出來(lái)浪費(fèi)不必要的時(shí)間。
2. c i n . t i e ( 0 ) cin.tie(0) cin.tie(0) 是取消 c i n , c o u t cin,cout cin,cout的綁定,進(jìn)一步加快執(zhí)行效率。
3.不能使用 e n d l endl endl,這個(gè)東西會(huì)強(qiáng)制 f l u s h b u f f e r flush\ buffer flush buffer,即刷新緩沖區(qū),而要使用
'\n' 。

相關(guān)案例查看更多