Simulation, map, make a mess. Use a bit of C11 's character.
#include <bits/stdc++.h>using namespacestd;typedef Map<string,int>Node;map<string,int>:: iterator it_id;Const intMaxnd =1e4; Node Nds[maxnd];intnds_cnt;#defineMP Make_pair#defineFi first#defineSe SecondinlineintIdConst string& s,node&FA) { if((it_id = Fa.find (s))! = Fa.end ())returnIt_id->second; Fa.insert (MP (s),++nds_cnt)); returnnds_cnt;}intCurfile,curfolder;voidDfsintu) { for(Auto It:nds[u]) {if(Nds[it.se].empty ()) {curfile++;Continue; } Elsecurfolder++; DFS (it.se); }}#defineCER (x) cout<<x<<endl;#definePB push_backintMain () {//freopen ("In.txt", "R", stdin);Ios_base::sync_with_stdio (false); strings; while(cin>>s) {Auto U=NDS; U= Nds+id (S.substr (0,1),*T); S.PB ('\\'); for(inti =3, j =3; I < (int) S.size (); i++){ if(S[i] = ='\\') {u= Nds+id (S.substr (j,i-j), *T); J= i+1; } } } intMaxfolder =0, Maxfile =0; for(Auto it:nds[0]){ for(Auto it2:nds[it.se]) {CurFolder= Curfile =0; DFS (it2.se); Maxfolder=Max (Maxfolder,curfolder); Maxfile=Max (maxfile,curfile); }} cout<<maxFolder<<' '<<maxFile<<Endl; return 0;}
Codeforces 66C Petya and File System