QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#700799#4666. Delete And WinMinche1992WA 0ms3716kbC++141.4kb2024-11-02 13:24:182024-11-02 13:24:40

Judging History

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

  • [2024-11-02 13:24:40]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3716kb
  • [2024-11-02 13:24:18]
  • 提交

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'