QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#395644 | #1369. Longest Common Subsequence | zedanov | WA | 2ms | 8684kb | C++20 | 1.1kb | 2024-04-21 16:50:04 | 2024-04-21 16:50:05 |
Judging History
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'