POJ2503本地/WSL运行正常,但是北大OJ过不了RE求助
  • 板块学术版
  • 楼主__vector__
  • 当前回复8
  • 已保存回复8
  • 发布时间2021/8/25 16:33
  • 上次更新2023/11/4 09:03:57
查看原帖
POJ2503本地/WSL运行正常,但是北大OJ过不了RE求助
507348
__vector__楼主2021/8/25 16:33

能过样例,但是交上去RE求助 本蒟蒻的代码:

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
using namespace std;
short tre[100001][60];
char fanyi[100001][60];
short val[1000001];
bool endstr[201];
char fy[100];//翻译后的
char yl[100];//原来的
int cnt = 1;
void insert(string str, int xb) {
    int len = str.length(), pos = 1;
    for (int i = 0; i < len; i++) {
        int ch = str[i] - 'a';
        if (!tre[pos][ch]) {
            tre[pos][ch] = ++cnt;
        }
        pos = tre[pos][ch];
    }
    val[pos] = xb;
    endstr[pos] = true;
}
int search(string str) {
    int len = str.length(), pos = 1;
    for (int i = 0; i < len; i++)
    {
        int ch = str[i] - 'a';
        pos = tre[pos][ch];
        if (!pos)
            return false;
    }
    if (endstr[pos]) {
        return val[pos];
    }
    return 0;
}
string tmp;
char ttmp[60];
int main() {
    int i = 0;
    char ch;
    while (scanf("%s%c", fanyi[++i], &ch)!=EOF)
    {
	    if(ch=='\n')break;
	    scanf("%s",yl);
	    insert(yl, i);
    }
    char cx[11];
    strcpy(cx,fanyi[i]);
    int ok = search(cx);
    if (!ok)
        printf("eh\n");
    else
        printf("%s\n", fanyi[ok]);
    while(scanf("%s", cx)!=EOF)
    {
       int ok = search(cx);
        if (!ok)
            printf("eh\n");
        else
            printf("%s\n", fanyi[ok]);
    }
    return 0;
}

2021/8/25 16:33
加载中...