結果

問題 No.130 XOR Minimax
コンテスト
ユーザー vjudge1
提出日時 2025-11-08 16:53:40
言語 C++14
(gcc 15.2.0 + boost 1.90.0)
コンパイル:
g++-15 -O2 -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
OLE  
(最新)
TLE  
(最初)
実行時間 -
コード長 1,014 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 968 ms
コンパイル使用メモリ 180,500 KB
実行使用メモリ 6,272 KB
最終ジャッジ日時 2026-07-16 10:01:49
合計ジャッジ時間 15,404 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample -- * 3
other OLE * 1 -- * 20
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include<bits/stdc++.h>
using namespace std;
const int N=3e6+5;
int nxt[N][26*2+10],cnt,num[N];
int val(char c){
    if(c<='9')return c-'0';
    if(c<='Z')return c-'A'+10;
    return c-'a'+10+26;
}
void add(string s){
    int now=0,len=s.size();
    for(int i=0;i<len;i++){
        int v=val(s[i]);
        if(!nxt[now][v])nxt[now][v]=++cnt;
        now=nxt[now][v];
        num[now]++;
    }
}
int query(string s){
    int now=0,len=s.size();
    for(int i=0;i<len;i++){
        int v=val(s[i]);
        if(!nxt[now][v])return 0;
        now=nxt[now][v];
    }
    return num[now];
}
string s;
int main()
{
    int t;
    scanf("%d",&t);
    while(t--){
        for(int i=0;i<=cnt;i++){
            for(int j=0;j<26*2+10;j++)
                nxt[i][j]=0;
            num[i]=0;
        }
        cnt=0;
        int n,m;
        scanf("%d%d",&n,&m);
        for(int i=1;i<=n;i++)
            cin>>s,add(s);
        while(m--){
            cin>>s;
            printf("%d\n",query(s));
        }
    }
    return 0;
}
0