C++ 中结构体数组长度有什么要求 ,POJ 2305 babelfish一题中,我只要把数组大小调成10000一下就会出现runtime error,10000以上就成功AC

问题遇到的现象和发生背景

问题描述:
你刚从滑铁卢搬到大城市。这里的人们讲一种难以理解的外语方言。幸运的是,你有一本字典来帮助你理解它们。

输入:
输入包括多达 100,000 个字典条目,然后是空白行,然后是多达 100,000 个单词的消息。每个字典条目都是一行包含一个英语单词,然后是一个空间和一个外语单词。字典中每个外来词只出现一次。信息是外语中的一系列单词,每行一个单词。输入中的每个单词最多是 10 个小写字母的序列。

输出:
输出是翻译成英文的消息,每行一个单词。字典中未写的外来词应翻译为"eh"。

示例输入

dog ogday
cat atcay
pig igpay
froot ootfray
loops oopslay

atcay
ittenkay
oopslay
样本输出

cat
eh
loops

问题相关代码,请勿粘贴截图

#include
#include
#include
using namespace std;
struct node
{
char s1[20], s2[20];
} a[100001];
int cmp(node a, node b)
{
return strcmp(a.s2, b.s2) < 0;
}
int main()
{
int i, low, mid, high;
int t = 1;
i= 0;
char s[50];
while (gets_s(s))
{
if (strlen(s) == 0)
break;
sscanf(s, "%s%s", a[i].s1, a[i].s2);
i++;
}
sort(a, a + i, cmp);
while (gets_s(s))
{
low = 0;
high = i- 1;
t = 1;
while (low <= high)
{
int mid = (low + high) / 2;
if (strcmp(s, a[mid].s2) == 0)
{
cout<< a[mid].s1<<endl;
t = 0;
break;
}
else if (strcmp(s, a[mid].s2) > 0)
low = mid + 1;
else
high = mid - 1;
}
if (t)
cout << "eh" << endl;
}
return 0;
}

#include
#include
#include
using namespace std;
struct node
{
char s1[20], s2[20];
} a[10000];
int cmp(node a, node b)
{
return strcmp(a.s2, b.s2) < 0;
}
int main()
{
int i, low, mid, high;
int t = 1;
i= 0;
char s[50];
while (gets_s(s))
{
if (strlen(s) == 0)
break;
sscanf(s, "%s%s", a[i].s1, a[i].s2);
i++;
}
sort(a, a + i, cmp);
while (gets_s(s))
{
low = 0;
high = i- 1;
t = 1;
while (low <= high)
{
int mid = (low + high) / 2;
if (strcmp(s, a[mid].s2) == 0)
{
cout<< a[mid].s1<<endl;
t = 0;
break;
}
else if (strcmp(s, a[mid].s2) > 0)
low = mid + 1;
else
high = mid - 1;
}
if (t)
cout << "eh" << endl;
}
return 0;
}

运行结果及报错内容
我的解答思路和尝试过的方法
我想要达到的结果
#include <iostream>
#include <sstream>
#include <unordered_map>

using namespace std;

int main()
{
    unordered_map<string, string> map;
    string line, word1, word2;
    while (getline(cin, line) && !line.empty())
    {
        istringstream is(line);
        is >> word1 >> word2;
        map[word2] = word1;
    }
    while (cin >> word2)
    {
        auto it = map.find(word2);
        if (it == map.end())
            cout << "eh\n";
        else
            cout << it->second << '\n';
    }
    return 0;
}