QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#730771#6825. Expenditure ReductionMattWA 56ms3848kbC++201.0kb2024-11-09 21:37:322024-11-09 21:37:33

Judging History

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

  • [2024-11-09 21:37:33]
  • 评测
  • 测评结果:WA
  • 用时:56ms
  • 内存:3848kb
  • [2024-11-09 21:37:32]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
#define endl '\n'
#define PII pair<int , int>
using namespace std;
const int N = 1e6 + 10;
int n , m ;
int mid = 1e9 + 7;

void matt(){
    string s , t;
    cin >> s >> t;
    map<char , set<int>>mp;
    for (int i = 0; i < s.size(); i++)
    {
        mp[s[i]].insert(i);
    }
    int i1 = 0 , j1 = 0 , maxx = N;
    for(auto x : mp[t[0]]){
        int j = x;
        int tr = 0;
        for (int i = 1; i < t.size(); i++)
        {
            int k;
            k = *mp[t[i]].upper_bound(j);
            if(k <= j){tr = 1; break;} 
            j = k;
        }
        if(tr) continue;
        if(j - x + 1 < maxx){
            i1 = x ;
            j1 = j ;
            maxx = j - x + 1;
        }
    }
    for (int i = i1; i <= j1; i++)
    {
        cout << s[i];
    }
    cout << endl;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int T = 1;
    cin >> T;
    while (T--)
    {
        matt();
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3848kb

input:

4
114514 15
shanghaicpc ac
aaabbbaaabbbccc abc
howdeliciousandfreshitis oishii

output:

145
aic
abbbc
owdeliciousandfreshiti

result:

ok T=4 (4 test cases)

Test #2:

score: -100
Wrong Answer
time: 56ms
memory: 3608kb

input:

10000
9fk811aek6newrfy7hvdsln282g1dcpa829bum5x1lpfdq9qd6 9f8ek6newyvdn282ca29b5x1ld9q
vg36oa5ncf4spe59gyplp1mi1or1hji2q0lcpubvxglbjjdyjm 365f4spe59glpm1oh2qpuvxjm
h604exipq7eg5gvy1n06mugqlxqyqd5kao0u12rsrfs2m4lpez h60e70muglxyd5k0u1le
33kmdcvnzvmkyjylt2kvck8fiy32jabu0rcnbhogqrnfi3hj6j 3mdcnzkyjlvk8f...

output:

9fk811aek6newrfy7hvdsln282g1dcpa829bum5x1lpfdq9q
36oa5ncf4spe59gyplp1mi1or1hji2q0lcpubvxglbjjdyjm
h604exipq7eg5gvy1n06mugqlxqyqd5kao0u12rsrfs2m4lpe
3kmdcvnzvmkyjylt2kvck8fiy32jabu0rcnbhogqrnfi3hj6
2f2ukqz1k3vbbs1x9o746i69vw675te94myxgqf0hesz0d6x4
12eqrshrg591ze2wjqpdcplm7ugkb9fo8v0xyk4r5ts4ikz86
akz...

result:

wrong answer Participant's answer doesn't contain vvh9merkifisyqryhpzjl3yu1y6 as subsequence (test case 1300)