http://118.190.20.162/view.page?gpid=T121

写的时候思路比较乱,不确定对不对,所以搜了别的答案,下面的答案是100分的。
https://blog.csdn.net/weixin_43693379/article/details/112725802

关于代码第149行 ios::sync_with_stdio(false);
https://blog.csdn.net/weixin_44015865/article/details/84974373
关于第150行 cin.tie(0);
https://blog.csdn.net/weixin_44772995/article/details/92839903

这是我没写完的,其实已经不对了,因为我用全局map的话就不能允许不同层级出现同名的目录或文件。

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <map>

using namespace std;

const int MAXN = 100000;
string father[MAXN];
//file files[MAXN];
//fold folds[MAXN];
map<string, file> files;
map<string, fold> folds;

struct file{
    int id;
    int size;
    fold(string name, int size):name(name), size(size) {}
};

struct fold{
    string name;
    int ld; //目录配额
    int lr; //后代配额 
    fold(string name):name(name), ld(0), lr(0) {}
};

bool isValid(string path){
    int len = path.size();
    if(path[0] != '/' || path[len-1] == '/'){
        return false;
    }
    for(int i = 0; i < len; i++){
        if(path[i] == '/' && path[i+1] == '/'){
            return false;
        }
    }
    return true;
}

bool isfile(string name){
    if(files.find(name) != files.end()){
        return true;
    }else{
        return false;
    }
}

bool isfold(string name){
    if(folds.find(name) != folds.end()){
        return true;
    }else{
        return false;
    }
}

string getname(string path){
    int len = path.size();
    int i = 1, k = 0;
    string tmp = "";
    while(i < len){
        if(path[i] == '/'){
            if(isfile(tmp)){
                return false;
            }else if(!isfold(tmp)){
                folds[tmp] = new fold(tmp);
            }
        }else{
            tmp += path[i];
        }
    }

}

string find(string name){  //查找根目录 
    if(name != father[name]){
        father[name] = find(father[name]);
    }
    return father[name];
} 

bool C(string path, int size){
    if()
} 

bool R(string path){
    if()
    return true; 
} 

bool Q(string path, int ld, int lr){
    if()
} 

int main(){
    int n;
    char order;
    string path;
    int size, ld, lr;
    scanf("%d", &n);
    bool flag;
    while(n--){
        cin >> order >> path;
        if(!isValid(path)){
            printf("N\n");
            continue;
        }
        if(order == 'C'){
            cin >> size;
            flag = C(path, size);    
        }else if(order == 'R'){
            flag = R(path);
        }else if(order == 'Q'){
            cin >> ld >> lr;
            flag = Q(path, ld, lr);
        }
        if(flag){
            printf("Y\n");
        }else{
            printf("N\n");
        }
    }
    return 0; 
}