比赛 20220418高一小测验 评测结果 EEEEEEEEEEEEEEEEEEEE
题目名称 网络连接 最终得分 0
用户昵称 dew52 运行时间 3.573 s
代码语言 C++ 内存使用 0.00 MiB
提交时间 2022-04-18 21:49:58
显示代码纯文本
#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;
const int MAXN = 1e4 + 5;
int n;
string ser[MAXN], cli[MAXN];
int check (string str);
int main()
{
    freopen("csp2021pj_network.in","r",stdin);
    freopen("csp2021pj_network.out","w",stdout);
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i)
    {
        string id; cin >> id;
        if (id == "Server")
        {
            cin >> ser[i];
            cout << "OK" << endl;
        }
        else if (id == "Client")
        {
            cin >> cli[i];
            cout << check(cli[i]) << endl;;
        }
    }
    return 0;
}
int check (string str)
{
    for (int i = 1; i <= n; ++i)
    {
        if (ser[i] == str)
        {
            return i;
        }
    }
}