QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#392199 | #8031. Gitignore | SocialPanda | TL | 1ms | 4076kb | C++14 | 1.8kb | 2024-04-17 11:15:38 | 2024-04-17 11:15:40 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define PII pair<int,int>
#define pb push_back
#define fi first
#define se second
void solve()
{
vector<vector<int>> v(10000);
map<string,int> rt;
map<string,int> mp;
map<int,int> sn;
int idx=1;
int n,m;
cin>>n>>m;
for(int i=1;i<=n;i++)
{
string tmp,word;
string father;
cin>>tmp;tmp+='/';
for(auto z:tmp)
{
if(z==tmp.size()-1)
{
word+="#FILE#";
mp[word]=idx++;
sn[mp[word]]=0;
if(father.empty())
{
rt[word]=1;
}
else
{
v[mp[father]].pb(mp[word]);
}
father=word;
word="";
}
else if(z=='/')
{
if(mp[word]==0) mp[word]=idx++;
sn[mp[word]]=0;
if(father.empty())
{
rt[word]=1;
}
else
{
v[mp[father]].pb(mp[word]);
}
father=word;
word="";
}
else word+=z;
}
}
for(int i=1;i<=m;i++)
{
string tmp,word;
cin>>tmp;tmp+='/';
string father;
for(auto z:tmp)
{
if(z==tmp.size()-1)
{
word+="#FILE#";
mp[word]=idx++;
sn[mp[word]]=1;
if(father.empty())
{
rt[word]=1;
}
else
{
v[mp[father]].pb(mp[word]);
}
father=word;
word="";
}
else if(z=='/')
{
if(mp[word]==0) mp[word]=idx++;
sn[mp[word]]=1;
if(father.empty())
{
rt[word]=1;
}
else
{
v[mp[father]].pb(mp[word]);
}
father=word;
word="";
}
else word+=z;
}
}
int ans=0;
for(auto z:rt)
{
//cout<<bfs(mp[z.fi])<<' ';
queue<int> q;
q.push(mp[z.fi]);
while(q.size())
{
int cur=q.front();
q.pop();
if(sn[cur]==0) ans++;
else
{
for(auto z:v[cur])
{
q.push(z);
}
}
}
}
cout<<ans<<endl;
}
int main()
{
int T=1;
cin>>T;
while(T--) solve();
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 4076kb
input:
2 3 0 data/train data/test model 3 1 data/train data/test model data/sample
output:
2 3
result:
ok 2 number(s): "2 3"
Test #2:
score: -100
Time Limit Exceeded
input:
5 0 10 szhps/mb/yz szhps/mb/fb/rf/auw szhps/or/ui hy/xkd/k szhps/mb/fb/rf/mu cf/rnd/wjv/xdda szhps/izh gi szhps/mb/fb/xwe hy/xkd/jbq 0 20 gjy/imp/mxuvi/z/ao gjy/s/zft/jxzm gjy/ob/mwvf/la gjy/imp/supe/oxne/p gjy/ob/mwvf/eums/agfb gjy/imp/mxuvi/z/anaj gjy/ob/mwvf/eums/tv gjy/ob/mwvf/eums/x/gg gjy/s/ak...
output:
0 0 0 0