[Codeforces 66C] Petya and File System (模拟)
2016-07-25 15:15
351 查看
Codeforces - 66C
给若干个文件路径,问子文件夹以及子文件最多为多少模拟题,可以直接用文件的绝对路径来表示一个文件
这样就不用担心不同路径文件的重名问题,也不用建树了
其次子文件夹和子文件数最多的肯定是根目录下的文件夹
用set维护一下这些文件夹的情况即可,set的好处是不用去重
#pragma comment(linker, "/STACK:102400000,102400000") #include <cstdio> #include <iostream> #include <cstdlib> #include <cstring> #include <algorithm> #include <cmath> #include <cctype> #include <map> #include <set> #include <queue> #include <bitset> #include <string> using namespace std; typedef pair<int,int> Pii; typedef long long LL; typedef unsigned long long ULL; typedef double DBL; typedef long double LDBL; #define MST(a,b) memset(a,b,sizeof(a)) #define CLR(a) MST(a,0) #define SQR(a) ((a)*(a)) #define PCUT puts("----------") int main() { #ifdef LOCAL freopen("in.txt", "r", stdin); // freopen("out.txt", "w", stdout); #endif string root, buff; map<string, set<string>> folder, files; while(cin >> buff) { int flr=0; for(int i=0; i<(int)buff.size(); i++) { if(buff[i]=='\\') { flr++; if(flr==2) root = buff.substr(0,i); else if(flr>2) folder[root].insert(buff.substr(0,i)); } } files[root].insert(buff); } int ans0=0, ans1=0; for(auto &pr:folder) ans0 = max(ans0, (int)pr.second.size()); for(auto &pr:files) ans1 = max(ans1, (int)pr.second.size()); printf("%d %d\n", ans0, ans1); return 0; }
相关文章推荐
- 移动端-自定义弹出选择器
- 白菜之Format,ActionListener,SimpleDateFormat,Timer
- JavaScript之正则表达式捕获
- mac安装Homebrew
- c++ 输出参数
- 关于Hibernate出现找不到实体类(Exception in thread "main" org.hibernate.MappingException: Unknown entity)
- c# 备份数据
- luigi学习2-在hadoop上运行Top Artists
- android studio -build
- block块和Protocol(协议)
- POJ 2485 Highways 最小生成树
- 图像拼接了解
- Android 使用Vitamio打造自己的万能播放器(6)――在线播放(播放列表)
- lightoj1101 ASecret Mission
- grub2的mbr分析
- Java提高篇——equals()与hashCode()方法详解
- import()函数
- c# 根据读取的配置信息删除某个目录及下所有文件
- OCX和DLL的区别
- Java:详解Java中super的几种用法并与this的区别