QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#395532#7076. Browser Gamessuibian_xiaozhao#WA 0ms7036kbC++23984b2024-04-21 15:59:412024-04-21 15:59:41

Judging History

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

  • [2024-04-21 15:59:41]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:7036kb
  • [2024-04-21 15:59:41]
  • 提交

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 * 50][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;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 7036kb

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: 5084kb

input:

3
hfotijo.njipzp.dpn/kb
hsbocmvfgboubtz.kq
ufoipv.ofu

output:

2
2
1

result:

wrong answer 1st lines differ - expected: '1', found: '2'