Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
51509 AK2022071337 最优子序列 C++ 运行出错 0 0 MS 256 KB 990 2022-07-13 11:48:52

Tests(0/20):


#include <bits/stdc++.h> using namespace std; int sum[3005]; int f[3005]; int main() { freopen("seq.in", "r", stdin); freopen("seq.out", "w", stdout); int n, k, t; string a; cin >> n >> k >> t; cin >> a; for(int i = 0; i < n; i ++ ) { for(int j = 0; j < n; j ++ ) { if(a[i] == a[j] && f[i] == 0) { sum [i]++; f[i] = 1; } } } int maxn = 0, x = 0, p = 0, q = 0; for(int i = 0; i < n; i ++) { maxn = max(maxn, sum[i]); if(sum[i] == maxn) { p = sum[i], q = i; } } x = n - maxn; if(x < maxn) { cout << maxn; } else { cout << x; } if(t == 1) { if(x < maxn) { for(int i = 0; i < p; i ++) { cout << a[q]; } } else { for(int i = 0; i < n; i ++) { if(sum[i] != maxn) { cout << a[i]; } } } } return 0; }


测评信息: