結果
| 問題 |
No.130 XOR Minimax
|
| コンテスト | |
| ユーザー |
vjudge1
|
| 提出日時 | 2025-11-08 16:53:40 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,014 bytes |
| コンパイル時間 | 4,624 ms |
| コンパイル使用メモリ | 163,228 KB |
| 実行使用メモリ | 62,996 KB |
| 最終ジャッジ日時 | 2025-11-08 16:58:49 |
| 合計ジャッジ時間 | 14,734 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 3 |
| other | TLE * 1 -- * 20 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:32:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
32 | scanf("%d",&t);
| ~~~~~^~~~~~~~~
main.cpp:41:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
41 | scanf("%d%d",&n,&m);
| ~~~~~^~~~~~~~~~~~~~
ソースコード
#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;
}
vjudge1