QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#405074 | #8031. Gitignore | Tomato_Fish# | WA | 1ms | 3928kb | C++14 | 1.3kb | 2024-05-05 10:30:58 | 2024-05-05 10:31:00 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=110,M=1010;
string s1[N],s2[N];
map<string,int> B[M];
vector<int> G[M];
int f[N],si[N],cnt;bool bk[N];
void dfs(int x){
si[x]=0;
for(auto y:G[x]){
dfs(y);
si[x]+=si[y];
}
if(bk[x]) si[x]=1,f[x]=0;
else{
f[x]=0;
for(auto y:G[x]) f[x]+=f[y];
if(si[x]==0&&x!=1) f[x]=1;
}
}
int main()
{
int T;scanf("%d",&T);
while(T--){
int n,m;
scanf("%d%d\n",&n,&m);
for(int i=1;i<=n;i++) getline(cin,s1[i]);
for(int i=1;i<=m;i++) getline(cin,s2[i]);
cnt=1;
for(int i=1;i<=n;i++){
int las=1,len=s1[i].size(),now=1;
for(int j=0;j<len;j++){
if(j==len-1||s1[i][j+1]=='/'){
string t;
for(int k=las;k<=j;k++)
t+=(s1[i][k]);
if(B[now][t]==0) B[now][t]=++cnt,G[now].push_back(cnt);
now=B[now][t];
las=j+2;
}
}
}
for(int i=1;i<=m;i++){
int las=1,len=s2[i].size(),now=1;
for(int j=0;j<len;j++){
if(j==len-1||s2[i][j+1]=='/'){
string t;
for(int k=las;k<=j;k++)
t+=(s2[i][k]);
if(B[now][t]==0) B[now][t]=++cnt,G[now].push_back(cnt);
now=B[now][t];
las=j+2;
}
}
bk[now]=true;
}
dfs(1);
printf("%d\n",f[1]);
for(int i=1;i<=cnt;i++) B[i].clear(),G[i].clear(),bk[i]=false;
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3928kb
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: 3824kb
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: 3836kb
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 1 0 1 2 1
result:
wrong answer 2nd numbers differ - expected: '2', found: '1'