CodeForces 66C Petya and File System (实现)
模拟题,map搞一搞。要想清楚一个结点应该是要通过一个字符串找到下一个结点,题目保证所以文件夹非空,所以只要判断一个结点是不是叶子结点就可以判断它是不是文件,用了点c11的特性。
#include<bits/stdc++.h>
using namespace std; typedef map<string,int> Node;
map<string,int>::iterator it_id;
const int maxnd = 1e4;
Node nds[maxnd];
int nds_cnt;
#define MP make_pair
#define fi first
#define se second inline int id(const string& s,Node& fa)
{
if((it_id = fa.find(s)) != fa.end()) return it_id->second;
fa.insert(MP(s,++nds_cnt));
return nds_cnt;
} int curFile,curFolder;
void dfs(int u)
{
for(auto it: nds[u]){
if(nds[it.se].empty()) { curFile++; continue; }
else curFolder++;
dfs(it.se);
}
} #define cer(x) cout<<x<<endl;
#define PB push_back int main()
{
//freopen("in.txt","r",stdin);
ios_base::sync_with_stdio(false);
string s;
while(cin>>s){
auto u = nds;
u = nds+id(s.substr(,),*u);
s.PB('\\');
for(int i = , j = ; i < (int)s.size(); i++){
if(s[i] == '\\'){
u = nds+id(s.substr(j,i-j),*u);
j = i+;
}
}
}
int maxFolder = ,maxFile = ; for(auto it: nds[]){
for(auto it2: nds[it.se]){
curFolder = curFile = ;
dfs(it2.se);
maxFolder = max(maxFolder,curFolder);
maxFile = max(maxFile,curFile);
}
}
cout<<maxFolder<<' '<<maxFile<<endl;
return ;
}
CodeForces 66C Petya and File System (实现)的更多相关文章
- Design and Implementation of the Sun Network File System
Introduction The network file system(NFS) is a client/service application that provides shared file ...
- 乌版图 read-only file system
今天在启动虚拟机的时候,运行命令svn up的时候,提示lock,并且read-only file system,这个....我是小白啊,怎么办?前辈在专心写代码,不好打扰,果断找度娘啊 于是乎,折腾 ...
- File system needs to be upgraded. You have version null and I want version 7
安装hbase时候报错: File system needs to be upgraded. You have version null and I want version 7 注: 我安装的hba ...
- Linux系统启动错误 contains a file system with errors, check forced解决方法
/dev/sda1 contains a file system with errors, check forced./dev/sda1: Inodes that were part of a cor ...
- Linux 执行partprobe命令时遇到Unable to open /dev/sr0 read-write (Read-only file system)
在使用fdisk创建分区时,我们会使用partprobe命令可以使kernel重新读取分区信息,从而避免重启系统,但是有时候会遇到下面错误信息"Warning: Unable to open ...
- 磁盘、分区及Linux文件系统 [Disk, Partition, Linux File System]
1.磁盘基础知识 1.1 物理结构 硬盘的物理结构一般由磁头与碟片.电动机.主控芯片与排线等部件组成:当主电动机带动碟片旋转时,副电动机带动一组(磁头)到相对应的碟片上并确定读取正面还是反面的碟面,磁 ...
- Linux File System
目录 . Linux文件系统简介 . 通用文件模型 . VFS相关数据结构 . 处理VFS对象 . 标准函数 1. Linux文件系统简介 Linux系统由数以万计的文件组成,其数据存储在硬盘或者其他 ...
- ORA-00245: control file backup failed; target is likely on a local file system
ORACLE11G RAC alert报错如下:Errors in file /u01/app/oracle/diag/rdbms/dljyzs/dljyzs1/trace/dljyzs1_ora_8 ...
- 读Avoiding the Disk Bottleneck in the Data Domain Deduplication File System
最近在思考和实践怎样应用重复数据删除技术到云存储服务中.找了些论文来读,其中<Avoiding the Disk Bottleneck in the Data Domain Deduplicat ...
随机推荐
- sql中的begin....end
Begin...End之间的是一个语句块,一般Begin...End用在 ( 相当于 {})whileif等语句中在T_SQL中,if/while后只能紧跟一条sql语句,如果有多条则应该用Beg ...
- 2019计蒜之道初赛4 B. 腾讯益智小游戏—矩形面积交(简单)(矩形交集)
B. 腾讯益智小游戏—矩形面积交(简单) 1000ms 262144K 腾讯游戏开发了一款全新的编程类益智小游戏,最新推出的一个小游戏题目是关于矩形面积交的.聪明的你能解出来吗?看下面的题目接招吧 ...
- WPF之触发器
简单触发器<Window x:Class="WpfApp.Window1" xmlns="http://schemas.microsoft.com/winfx/20 ...
- codeforces590E Birthday【AC自动机+Floyd+匈牙利算法】
因为没有重复串,所以把有包含关系的串连边之后是个DAG,也就是二分图,就变成求二分图的最大独立集=n-最小点覆盖=n-最大匹配 关于包含关系,建出AC自动机,然后把串放上去找子串,但是如果每次都一路找 ...
- JAVA之动态编译
通过Java动态生成class文件 今天说下JAVA中的动态编译,这个功能根据我现在的了解好像没有见到过用的,我Jio的吧,现在的一些在线代码编缉器可以用到了,这个具体我也不是很清楚.感兴趣的大家可以 ...
- 源码构建Apollo以及改造
1. 下载release版本 本次构建的是1.4.0的版本 2. 初始化数据库信息 数据库表信息 2.1 修改注册中心配置 初始化数据库表后,需要修改 ApolloConfigDB.ServerCon ...
- sonar扫描android项目配置 mac版
一. 下载安装 JDK8以上 SonarQube SonarQube Scanner 1. 解压缩SonarQube和SonarQube Scanner,直接运行SonarQube中bin目录下 ...
- Hive进阶_Hive的客户端操作
启动远程客户端 # hive --service hiveserver2获取连接-〉创建运行环境-〉执行HQL-〉处理结果-〉释放资源 工具类 package demo.utils; import j ...
- jsp中c标签的使用
jsp中c标签的使用 核心标签库 它是JSTL中的核心库,为日常任务提供通用支持,如显示和设置变量.重复使用一组项目.测试条件和其他操作(如导入和重定向Web内容).Core标签按功能可分为4种类型: ...
- mongodb的投影
mongodb 投影意思是只选择必要的数据而不是选择一个文件的数据的整个.如果一个文档有5个字段,需要显示只有3个,然后选择其中只有3个字段. find() 方法 MongoDB 的find()方法, ...