QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#700776#4666. Delete And WinMinche1992WA 0ms3716kbC++141.4kb2024-11-02 13:23:092024-11-02 13:23:22

Judging History

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

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

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;
    cin >> T;
    getline(cin, s);
    while (T--) {
        solve();
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3716kb

input:

pqsrpspqz
pqrpqz

output:


result:

wrong answer Answer contains longer sequence [length = 1], but output contains 0 elements