Codeforces 66C Petya and File System

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.