QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#392211#8031. GitignoreSocialPandaWA 1ms4152kbC++141.5kb2024-04-17 11:22:312024-04-17 11:22:32

Judging History

你现在查看的是最新测评结果

  • [2024-04-17 11:22:32]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:4152kb
  • [2024-04-17 11:22:31]
  • 提交

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<pair<string,int>,int> rt;
	map<pair<string,int>,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+='/';
		int lv=1;
		for(auto z:tmp)
		{
			if(z=='/')
			{
				if(mp[{word,lv}]==0) mp[{word,lv}]=idx++;
				sn[mp[{word,lv}]]=0;
				if(father.empty())
				{
					rt[{word,lv}]=1;
				}
				else
				{
					v[mp[{father,lv-1}]].pb(mp[{word,lv}]);
				}
				father=word;
				word="";
				lv++;
			}
			else word+=z;
		}
	}
	for(int i=1;i<=m;i++)
	{
		string tmp,word;
		string father;
		cin>>tmp;tmp+='/';
		int lv=1;
		for(auto z:tmp)
		{
			if(z=='/')
			{
				if(mp[{word,lv}]==0) mp[{word,lv}]=idx++;
				sn[mp[{word,lv}]]=1;
				if(father.empty())
				{
					rt[{word,lv}]=1;
				}
				else
				{
					v[mp[{father,lv-1}]].pb(mp[{word,lv}]);
				}
				father=word;
				word="";
				lv++;
			}
			else word+=z;
		}
	}
	int ans=0;
	for(auto z:rt)
	{
		//cout<<bfs(mp[z.fi])<<' ';
		queue<int> q;
		q.push(mp[{z.fi.fi,z.fi.se}]);
		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();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3764kb

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: 0
Accepted
time: 1ms
memory: 4152kb

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
0

result:

ok 5 number(s): "0 0 0 0 0"

Test #3:

score: -100
Wrong Answer
time: 1ms
memory: 3860kb

input:

6
0 14
evs
r/gvzgs/pbs/b/riip
r/gvzgs/brps
r/gvzgs/pbs/nj
r/gvzgs/bl/rhyx/var
hg/tdcl
r/gvzgs/pbs/fbs/rle
r/gvzgs/pt/ncvnc/le/zzpy
r/gvzgs/pbs/fbs/xf
wux/ts/jxc
bo/olh
mx/yuw
r/gvzgs/pt/ncvnc/le/gxv
bo/axyv
2 11
nt/tulqv
m/i/i
n
noqdi/lt
m/cim
noqdi/jnz
m/i/k
m/otb
m/i/gd
nt/ndxv
nt/x/hta
noqdi/rxbb...

output:

0
4
0
36
5
468

result:

wrong answer 2nd numbers differ - expected: '2', found: '4'