QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#59691 | #1369. Longest Common Subsequence | abdelrahman001# | WA | 4ms | 3496kb | C++20 | 1.0kb | 2022-10-31 19:35:19 | 2022-10-31 19:35:20 |
Judging History
answer
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;
const int N = 1e5 + 5;
int n, k;
int pos[26];
int get(vector<int> &seq, int high, int x) {
int low = 0, mid, j;
while(low <= high) {
mid = low + high >> 1;
if(seq[mid] >= x)
high = mid - 1, j = mid;
else
low = mid + 1;
}
return j;
}
int main() {
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin >> n >> k;
for(int i = 0;i < n;i++) {
string s;
cin >> s;
for(int j = 0;j < k;j++) {
int cur = s[j] - 'A';
pos[cur] = max(pos[cur], j);
}
}
int len = 1;
vector<int> seq(k, 0);
seq[0] = pos[0];
for(int i = 1;i < k;i++) {
if(pos[i] < seq[0])
seq[0] = pos[i];
else if(pos[i] > seq[len - 1])
seq[len++] = pos[i];
else {
int j = get(seq, len - 1, pos[i]);
seq[j] = pos[i];
}
}
cout << len;
return 0;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 4ms
memory: 3496kb
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:
5
result:
wrong answer 1st lines differ - expected: '12', found: '5'