QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#395527 | #7076. Browser Games | suibian_xiaozhao# | WA | 0ms | 7096kb | C++23 | 984b | 2024-04-21 15:59:03 | 2024-04-21 15:59:03 |
Judging History
answer
//
// Created by DELLPC on 24-4-21.
#include <bits/stdc++.h>
using namespace std;
const int maxn = 5e4 + 5;
string s[maxn];
int en(char c) {
if(c == '/')
return 0;
if(c == '.')
return 1;
return c - 'a' + 2;
}
int nex[maxn * 10][30], cn[maxn];
int cnt = 1;
void insert(string ss) {
int p = 1;
int n = ss.size();
for(int i = 0; i < n; i++) {
if(!nex[p][en(ss[i])])
nex[p][en(ss[i])] = ++cnt;
p = nex[p][en(ss[i])];
cn[p]++;
}
}
int sol(string ss) {
int p = 1;
int n = ss.size();
for(int i = 0; i < n; i++) {
p = nex[p][en(ss[i])];
if(cn[p] == 1) {
return i + 1;
}
}
return n;
}
int main() {
int n;
cin >> n;
for(int i = 0; i < n; i++) {
cin >> s[i];
insert(s[i]);
}
for(int i = 0; i < n; i++) {
cout << sol(s[i]) << endl;
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 6308kb
input:
3 ufoipv.ofu hsbocmvfgboubtz.kq hfotijo.njipzp.dpn/kb
output:
1 2 2
result:
ok 3 lines
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 7096kb
input:
3 hfotijo.njipzp.dpn/kb hsbocmvfgboubtz.kq ufoipv.ofu
output:
2 2 1
result:
wrong answer 1st lines differ - expected: '1', found: '2'