QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#700799 | #4666. Delete And Win | Minche1992 | WA | 0ms | 3716kb | C++14 | 1.4kb | 2024-11-02 13:24:18 | 2024-11-02 13:24:40 |
Judging History
answer
#include <iostream>
#include <vector>
#include <string>
using namespace std;
string s, t;
int len1, len2;
void solve() {
getline(cin, s);
getline(cin, t);
int len1 = s.length();
int len2 = t.length();
int ans = 0;
int i = 0, j = 0;
if (len1 == len2 && s == t) {
cout << 1 << '\n';
return;
}
bool deg = 0;
int ans2 = len1;
int tmp = 0;
for (; i<len1 && j<len2; i++) {
if (s[i] < t[j]) {
cout << min(ans, ans2) << '\n';
return;
}
else if (s[i] > t[j]) {
ans++;
if (ans > ans2) {
cout << ans2 << '\n';
return;
}
deg = 1;
}
else {
int k = 1;
for (; k+i<len1; k++) {
if (s[k+i] < t[j]) break;
}
ans2 = min(ans2, ans+k);
if (deg) {
deg = 0;
}
if (j < len2-1) j++;
else {
cout << ans2 << '\n';
return;
}
}
}
cout << min(ans, ans2) << '\n';
}
int main() {
// freopen("string.in", "r", stdin);
// freopen("string.out", "w", stdout);
int T;
T = 1;
getline(cin, s);
while (T--) {
solve();
}
return 0;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3716kb
input:
pqsrpspqz pqrpqz
output:
0
result:
wrong answer 1st numbers differ - expected: '2', found: '0'