QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#608555 | #8031. Gitignore | LJY_ljy | WA | 1ms | 3980kb | C++11 | 2.7kb | 2024-10-03 23:10:08 | 2024-10-03 23:10:08 |
Judging History
answer
#include <iostream>
#include <cstdio>
#include <cstring>
#include <set>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
using namespace std;
const int MAXN = 1e3 + 10;
int n, m, eid;
char str[MAXN];
string Str;
map<string, int> M[MAXN];
vector<int> G[MAXN];
set<int> Child[MAXN], Front;
bool used[MAXN];
int dfs(int k) {
if (!used[k]) return 1;
else {
int ans = 0;
for (auto x: Child[k]) {
ans += dfs(x);
}
return ans;
}
}
int main() {
int t;
scanf("%d", &t);
for (int u = 1; u <= t; u++) {
for (int i = 0; i < MAXN; i++) used[i] = false;
eid = 0;
scanf("%d %d", &n, &m);
for (int i = 0; i < MAXN; i++)
M[i].clear();
for (int i = 1; i <= n + m; i++) G[i].clear();
for (int i = 1; i <= n; i++) {
int cnt = 0;
scanf("%s", str + 1);
int len = strlen(str + 1);
Str = "";
bool flag = true;
for (int j = 1; j <= len; j++) {
if ('a' <= str[j] && str[j] <= 'z') {
Str = Str + str[j];
} else {
cnt++;
if (flag) {
if (M[cnt][Str] == 0) {
M[cnt][Str] = ++eid;
flag = false;
}
G[i].push_back(M[cnt][Str]);
} else {
G[i].push_back(++eid);
}
Str = "";
}
}
cnt++;
if (flag) {
if (M[cnt][Str] == 0) {
M[cnt][Str] = ++eid;
flag = false;
}
G[i].push_back(M[cnt][Str]);
} else {
G[i].push_back(++eid);
}
}
for (int i = n + 1; i <= n + m; i++) {
int cnt = 0;
scanf("%s", str + 1);
int len = strlen(str + 1);
Str = "";
bool flag = true;
for (int j = 1; j <= len; j++) {
if ('a' <= str[j] && str[j] <= 'z') {
Str = Str + str[j];
} else {
cnt++;
if (flag) {
if (M[cnt][Str] == 0) {
M[cnt][Str] = ++eid;
flag = false;
}
G[i].push_back(M[cnt][Str]);
} else {
G[i].push_back(++eid);
}
Str = "";
}
}
cnt++;
if (flag) {
if (M[cnt][Str] == 0) {
M[cnt][Str] = ++eid;
flag = false;
}
G[i].push_back(M[cnt][Str]);
} else {
G[i].push_back(++eid);
}
}
// for (int i = 1; i <= n + m; i++) {
// for (int j = 0; j < G[i].size(); j++)
// cout << G[i][j] << " ";
// cout << endl;
// }
for (int i = 0; i < MAXN; i++) Child[i].clear();
Front.clear();
for (int i = 1; i <= n; i++) {
Front.insert(G[i][0]);
for (int j = 0; j < G[i].size() - 1; j++)
Child[G[i][j]].insert(G[i][j + 1]);
}
for (int i = n + 1; i <= n + m; i++) {
for (int j = 0; j < G[i].size() - 1; j++)
used[G[i][j]] = true;
used[G[i][G[i].size() - 1]] = true;
}
int Ans = 0;
for (auto x:Front) {
Ans += dfs(x);
}
printf("%d\n", Ans);
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3956kb
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: 0ms
memory: 3916kb
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: 0
Accepted
time: 0ms
memory: 3980kb
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 2 0 1 2 1
result:
ok 6 numbers
Test #4:
score: -100
Wrong Answer
time: 0ms
memory: 3968kb
input:
5 6 10 j/yems/b/oqr/jl usm/pa/wv j/gj/uq j/epdo/u j/epdo/r j/yems/fg j/epdo/nbck usm/nnbr/pik usm/pa/nqf j/e usm/pa/kub j/epdo/vvk/eno/zs/mtz j/epdo/vvk/jvf j/epdo/vvk/eno/rdgm usm/pa/zp j/epdo/fe/qc 3 9 qn/wiy/wneh qn/wiy/uc f/yp dpb/dq dpb/fv dpb/fyvn dpb/s/iias/ddu/fnx jp/nu dpb/s/odpn/nloco f/kt...
output:
6 3 5 5 4
result:
wrong answer 1st numbers differ - expected: '5', found: '6'