请问C语言一个小疑点

请教C语言一个小问题
这是一道水题,题目内容不是重点,我是想请教这两份代码的区别,为什么一份就是accept,另一份却是Output Limit Exceeded ,谢谢

题目内容如下:
请问C语言一个小疑点

代码一:(提交OJ后accept)
#include<stdio.h>

int main()
{
    char b[21],g[21],x[9],ch;
    int t;

    scanf("%d",&t);

    while(t--)
    {
        scanf("%s%s%s",b,g,x);

        printf("%s will survive\n",g);
    }

    return 0;
}

代码二:(提交后是Output Limit Exceeded)
#include<stdio.h>

int main()
{
    char b[21],g[21],x[9];
    int t;

    scanf("%d",&t);

    getchar();

    while(t--)
    {
        gets(b);
        gets(g);
        gets(x);

    printf("%s will survive\n",g);
    }

    return 0;
}
------解决思路----------------------
scanf的%s是读取到空格、回车、制表符,而gets只会读取到回车。
你用gets的话,三个人的名字会存成一个名字。
------解决思路----------------------
使用scanf();
空白字符(空格、回车、制表符)可区分数据
使用gets();
一般回车才可区分数据
gets()
The gets function reads a line from the standard input stream stdin and stores it in buffer. The line consists of all characters up to and including the first newline character ('\n'). gets then replaces the newline character with a null character ('\0') before returning the line. In contrast, the fgets function retains the newline character.