跳到正文

题解

题解:P16268 [蓝桥杯 2026 省 Java B 组] 游戏指令解析器

hunter0608约 1 分钟
原文
文章信息与版本

文章信息

收录
2026年4月20日
更新
2026年4月28日
篇幅
约 1 分钟
题目
P16268

版本

  1. v1当前

这字符串, 还普及! 没啥难度啊

C++
#include<bits/stdc++.h>
using namespace std;
string a[105],b[105];
int main(){
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=1;i<=m;i++) cin>>b[i];
    for(int i=1;i<=m;i++)
    {
        int s=0,p=0;
        for(int j=1;j<=n;j++)
        {
            if(a[j].find(b[i])==0)
            {
                s++;
                p=j;
            }
        }
        if(s==0) cout<<"unknown"<<endl;
        else if(s==1) cout<<a[pos]<<endl;
        else cout<<"ambiguous"<<endl;
    }
    return 0;
}
原文