QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#395646#1369. Longest Common SubsequencezedanovWA 0ms12344kbC++201.2kb2024-04-21 16:53:332024-04-21 16:53:34

Judging History

你现在查看的是最新测评结果

  • [2024-04-21 16:53:34]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:12344kb
  • [2024-04-21 16:53:33]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

#define zedanov                   \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0);
#define ll long long
#define el "\n"

const int N = 1e5 + 5;
int n, k;
string a[N];
int appear[28][N], mem[28];
int solve(int cur, int cnt = 0)
{
    if (cnt == k)
        return 0;
    int &ret = mem[cur];
    if (~ret)
        return cur;
    
    ret = 0;
    for (int c = 0; c < k; c++)
    {
        if (c == cur)
            continue;
        bool can = 1;
        for (int i = 0; i < n; i++)
        {
            if (appear[c][i] < appear[cur][i])
                can = 0;
        }
        if (can)
            ret = max(ret, 1 + solve(c, cnt + 1));
    }
    return ret;
}
void doWork()
{
    cin >> n >> k;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < k; j++)
            appear[a[i][j] - 'A'][i] = j;
    }
    memset(mem, -1, sizeof mem);
    cout << solve(27);
}

signed main()
{
    zedanov int t = 1;
    // cin >> t;
    while (t--)
        doWork();

    return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 12344kb

input:

6113 13
DALIBKGHEMJFC
DAHLIBKGEMJFC
DALIBKGEMJFHC
DAHLIBKGEMJFC
DALIBHKGEMJFC
DALHIBKGEMJFC
DHALIBKGEMJFC
DALIBKGEHMJFC
DAHLIBKGEMJFC
DALIHBKGEMJFC
DALIBKHGEMJFC
DALIHBKGEMJFC
DALHIBKGEMJFC
DALIBKGEMJFCH
DALIBKGEMJHFC
DAHLIBKGEMJFC
DALIBKGEMJFHC
DALIBKGEMHJFC
DALIBHKGEMJFC
DALIBKHGEMJFC
DALIBKGEMHJF...

output:

16

result:

wrong answer 1st lines differ - expected: '12', found: '16'