QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#395644#1369. Longest Common SubsequencezedanovWA 2ms8684kbC++201.1kb2024-04-21 16:50:042024-04-21 16:50:05

Judging History

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

  • [2024-04-21 16:50:05]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:8684kb
  • [2024-04-21 16:50:04]
  • 提交

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[27][N], mem[27];
int solve(int cur, int cnt = 0)
{
    if (cnt == n)
        return 0;
    int 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;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 2ms
memory: 8684kb

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:

0

result:

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