QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#59691#1369. Longest Common Subsequenceabdelrahman001#WA 4ms3496kbC++201.0kb2022-10-31 19:35:192022-10-31 19:35:20

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-10-31 19:35:20]
  • 评测
  • 测评结果:WA
  • 用时:4ms
  • 内存:3496kb
  • [2022-10-31 19:35:19]
  • 提交

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;
}


Details

Tip: Click on the bar to expand more detailed information

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'