代码
---
```cpp
#include<assert.h>
#include<cstring>
#include<iostream>
#include<map>
#include<set>
#define int long long
using namespace std;
struct sss
{
int q,w,nxt;
}a[1000005];
struct file
{
int size,state,fa;
string name;
}f[1000005];
struct user
{
int pos,type,state;
}u[1000005];
struct downup
{
int v,tot,sum,pos,state;
};
bool operator<(const downup &a,const downup &s)
{
return a.v<s.v;
}
int cnt,head[1000005],mun,msf,muf,num,pos,tot,on,Ti,T;
string s;
map<string,int>mp;
set<downup>st,st1;
void adde(int q,int w)
{
a[++cnt].q=q;
a[cnt].w=w;
a[cnt].nxt=head[q];
head[q]=cnt;
}
int fnd(int x,string s)
{
for(int i=head[x];i;i=a[i].nxt)
{
if(f[a[i].w].name==s)return a[i].w;
}
return -1;
}
void dfs(int x,int p,int o)
{
if(f[x].state==p)return;
f[x].state=p;
if(f[x].fa)dfs(f[x].fa,p,o),f[f[x].fa].size+=o;;
}
signed main()
{
scanf("%lld%lld%lld",&mun,&msf,&muf);
f[++num].size=-1;
pos=num;
while(pos)
{
cin>>s;
if(s[0]=='-'){pos=f[pos].fa;continue;}
f[++num].fa=pos;
f[num].name=s;
f[num].state=1;
adde(pos,num);
scanf("%lld",&f[num].size);
f[pos].size+=f[num].size;
if(!f[num].size)pos=num;
}
int P=0;
while(1)
{
P++;
cin>>s;
if(s=="down")break;
Ti=atoi(s.c_str());
while(T<Ti)
{
T++;
for(auto x:st)
{
int pmuf=msf/st.size();
x.v=min(pmuf,muf);
x.sum+=x.v;
if(x.sum>x.tot)
{
if(x.state)dfs(x.pos,1,x.tot);
else dfs(x.pos,1,0);
}
else st1.insert(x);
}
st=st1;
st1.clear();
for(auto x:st)if(x.state)dfs(x.pos,2,0);
}
cin>>s;
if(mp.find(s)==mp.end())mp[s]=++tot;
int user=mp[s];
char op[15];
scanf("%s",op);
if(strlen(op)==7)
{
int A;
scanf("%lld",&A);
if(on<mun&&!u[user].state)
{
puts("success");
u[user].state=1;
u[user].pos=1;
u[user].type=A;
on++;
}
else puts("unsuccess");
}
else if(op[0]=='q')
{
if(u[user].state)
{
puts("success");
u[user].state=0;
on--;
}
else puts("unsuccess");
}
else if(strlen(op)==2)
{
string fl;
cin>>fl;
int o=fnd(u[user].pos,fl);
if(o!=-1&&f[o].state==1&&u[user].state)
{
puts("success");
u[user].pos=o;
}
else puts("unsuccess");
}
else if(strlen(op)==4)
{
if(u[user].pos!=1&&u[user].state)
{
u[user].pos=f[u[user].pos].fa;
puts("success");
}
else puts("unsuccess");
}
else if(strlen(op)==8)
{
string fl;
cin>>fl;
int o=fnd(u[user].pos,fl);
if(o!=-1&&u[user].type==2&&u[user].state&&f[o].state==1)
{
st.insert({0,f[o].size,0,o,0});
puts("success");
}
else puts("unsuccess");
}
else if(strlen(op)==6)
{
string fl;
int size;
cin>>fl;
scanf("%lld",&size);
int o=fnd(u[user].pos,fl);
if(o==-1&&u[user].state&&u[user].type==1)
{
f[++num].fa=u[user].pos;
f[num].name=fl;
adde(u[user].pos,num);
st.insert({0,f[num].size=size,0,num,1});
puts("success");
}
else puts("unsuccess");
}
else assert(0);
}
}
/*
5 200 200
unzip.exe 100
xxxx 50
bin 0
tpx.exe 200
turbo.exe 300
tpx.tp 400
temp 0
-
-
readme.txt 100
-
0 ares connect 2
0 ares download zip.exe
1 ares download bin
5 ares download xxxx
6 ares cd bin
6 ares connect 1
6 ares quit
7 ares connect 1
7 rosen connect 2
7 ares cd bin
8 ares upload A 300
9 rosen download bin
10 rosen download bin
down
1 200 200
C 0
D 100
-
-
0 A connect 2
down
*/
```
by FatOldEight @ 2023-03-24 15:18:51
只用找到一组hack就行了
by FatOldEight @ 2023-03-24 15:26:57
这么短?
by xuezhiyu @ 2023-11-22 22:05:07