知識(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í)提供便捷的支持!
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)案例查看更多
相關(guān)閱讀
- 旅游網(wǎng)站建設(shè)
- 公眾號(hào)模板消息
- 云南小程序開(kāi)發(fā)費(fèi)用
- typescript
- 云南網(wǎng)站開(kāi)發(fā)
- 前端技術(shù)
- 小程序模板開(kāi)發(fā)公司
- 制作一個(gè)小程序
- 網(wǎng)站建設(shè)價(jià)格
- 汽車報(bào)廢拆解管理系統(tǒng)
- 國(guó)內(nèi)知名網(wǎng)站建設(shè)公司排名
- 網(wǎng)站建設(shè)案例
- 云南軟件開(kāi)發(fā)
- 小程序被攻擊
- 開(kāi)發(fā)微信小程序
- 小程序公司
- 云南網(wǎng)站建設(shè)費(fèi)用
- 百度快速排名
- 云南軟件定制
- 昆明小程序開(kāi)發(fā)
- 網(wǎng)站建設(shè)專業(yè)品牌
- 小程序制作
- 報(bào)廢車
- 云南省建設(shè)廳官方網(wǎng)站
- 報(bào)廢車管理
- 汽車報(bào)廢回收管理軟件
- 網(wǎng)站收錄
- flex
- 汽車拆解管理系統(tǒng)
- 云南小程序開(kāi)發(fā)課程