QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#228157#6516. New but Nostalgic Problemsjk1686959421WA 17ms37948kbC++201.5kb2023-10-28 12:58:462023-10-28 12:58:46

Judging History

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

  • [2023-10-28 12:58:46]
  • 评测
  • 测评结果:WA
  • 用时:17ms
  • 内存:37948kb
  • [2023-10-28 12:58:46]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
int p[1000010][26],cnt=0,res[1000010],ma=-1;
void add(string s){
    int e=0;
    for(int i=0;i<s.size();i++){
        int x=s[i]-'a';
        if(!p[e][x]){
            p[e][x]=++cnt;
        }
        e=p[e][x];
        res[e]++;
    }
}
void f(string s){
    int e=0,len=0;
    for(int i=0;i<s.size();i++){
        int x=s[i]-'a';
        e=p[e][x];
        len++;
        if(res[e]>1){
            ma=max(ma,len);
        }
    }
}
vector<string>ans;
void ff(string s){
    int e=0,len=0;
    for(int i=0;i<s.size();i++){
        int x=s[i]-'a';
        e=p[e][x];
        len++;
        if(len==ma&&res[e]>1){
            ans.push_back(s.substr(0,len));
        }
    }
}
string a[1000010];
void slove(){
    ma=-1;
    ans.clear();
    cnt=0;
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        add(a[i]);
    }
    for(int i=1;i<=n;i++){
        f(a[i]);
    }
    for(int i=1;i<=n;i++){
        ff(a[i]);
    }
    /*sort(ans.begin(),ans.end());
    for(int i=0;i<ans.size();i++){
        cout<<ans[i]<<endl;
    }*/
    if(ans.size()){
        cout<<ans[0]<<endl;
    }else{
        cout<<"EMPTY"<<endl;
    }
    for(int i=0;i<=cnt;i++){
        res[i]=0;
        for(int j=0;j<26;j++){
            p[i][j]=0;
        }
    }
}
signed main(){
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    int _=1;
    cin>>_;
    while(_--){
        slove();
    }
}

詳細信息

Test #1:

score: 100
Accepted
time: 11ms
memory: 37948kb

input:

2
5 3
gdcpc
gdcpcpcp
suasua
suas
sususua
3 3
a
b
c

output:

gdcpc
EMPTY

result:

ok 2 lines

Test #2:

score: -100
Wrong Answer
time: 17ms
memory: 37940kb

input:

20000
5 3
apveofpr
irdbqk
rnionnjjrk
wrpihlsw
ofylfsriof
5 4
iiltghqg
kybhogptqf
jfnmqxzrdq
rpztcluq
tzmnrcjae
5 5
ysp
vujmkkcutl
ksawqeiiaf
waukilaq
wmlsutlued
5 3
pikybt
yiqmqvtjeq
tyrsoihf
vnvjrxpus
cuubpacubb
5 2
rihuvikhg
twrsuoervz
ukiekoohw
eysqgndpf
sxswpeqtaf
5 5
vxzhicbp
nvtdbgqal
jilppvpt...

output:

EMPTY
EMPTY
w
EMPTY
EMPTY
EMPTY
EMPTY
EMPTY
EMPTY
EMPTY
EMPTY
EMPTY
t
EMPTY
EMPTY
m
EMPTY
a
EMPTY
EMPTY
EMPTY
EMPTY
EMPTY
e
r
EMPTY
o
v
EMPTY
w
EMPTY
EMPTY
t
EMPTY
s
z
v
EMPTY
EMPTY
EMPTY
EMPTY
EMPTY
EMPTY
w
EMPTY
EMPTY
EMPTY
EMPTY
EMPTY
EMPTY
EMPTY
EMPTY
w
u
EMPTY
EMPTY
EMPTY
EMPTY
EMPTY
EMPTY
EMPT...

result:

wrong answer 13th lines differ - expected: 'EMPTY', found: 't'