Submission #74678478


Source Code Expand

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
  ll ans = 0,L = 0;
  string S,T;
  cin >> S >> T;
  vector<ll> X(S.size(),-1),Y(T.size(),-1);
  for(ll i = 0;i < S.size();i++){
    for(ll j = T.size() - 1;j >= 0;j--){
      if(S[i] != T[j]){
        continue;
      }
      if(j == 0){
        Y[0] = i;
      }
      else{
        if(Y[j - 1] == -1){
          continue;
        }
        Y[j] = Y[j - 1];
      }
      if(j == T.size() - 1){
        X[i] = Y[j];
      }
    }
  }
  for(ll i = 0;i < S.size();i++){
    if(X[i] != -1){
      L = X[i] + 1;
    }
    ans+=i - L + 1;
  }
  cout << ans;
}

Submission Info

Submission Time
Task D - No-Subsequence Substring
User MI6174
Language C++23 (GCC 15.2.0)
Score 400
Code Size 671 Byte
Status AC
Exec Time 13 ms
Memory 5364 KiB

Compile Error

./Main.cpp: In function 'int main()':
./Main.cpp:10:18: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |   for(ll i = 0;i < S.size();i++){
      |                ~~^~~~~~~~~~
./Main.cpp:24:12: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |       if(j == T.size() - 1){
      |          ~~^~~~~~~~~~~~~~~
./Main.cpp:29:18: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |   for(ll i = 0;i < S.size();i++){
      |                ~~^~~~~~~~~~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 3
AC × 56
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt, 01_random_19.txt, 01_random_20.txt, 01_random_21.txt, 01_random_22.txt, 01_random_23.txt, 01_random_24.txt, 01_random_25.txt, 01_random_26.txt, 01_random_27.txt, 01_random_28.txt, 01_random_29.txt, 01_random_30.txt, 01_random_31.txt, 01_random_32.txt, 01_random_33.txt, 01_random_34.txt, 01_random_35.txt, 01_random_36.txt, 01_random_37.txt, 01_random_38.txt, 01_random_39.txt, 01_random_40.txt, 01_random_41.txt, 01_random_42.txt, 01_random_43.txt, 01_random_44.txt, 01_random_45.txt, 01_random_46.txt, 01_random_47.txt, 01_random_48.txt, 01_random_49.txt, 01_random_50.txt, 01_random_51.txt, 01_random_52.txt, 01_random_53.txt, 01_random_54.txt, 01_random_55.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 1 ms 3420 KiB
00_sample_01.txt AC 1 ms 3584 KiB
00_sample_02.txt AC 1 ms 3508 KiB
01_random_03.txt AC 6 ms 4600 KiB
01_random_04.txt AC 7 ms 4532 KiB
01_random_05.txt AC 3 ms 4060 KiB
01_random_06.txt AC 4 ms 4212 KiB
01_random_07.txt AC 4 ms 4224 KiB
01_random_08.txt AC 7 ms 5180 KiB
01_random_09.txt AC 9 ms 5176 KiB
01_random_10.txt AC 8 ms 5176 KiB
01_random_11.txt AC 10 ms 5172 KiB
01_random_12.txt AC 5 ms 5196 KiB
01_random_13.txt AC 5 ms 5196 KiB
01_random_14.txt AC 8 ms 5252 KiB
01_random_15.txt AC 9 ms 5212 KiB
01_random_16.txt AC 10 ms 5200 KiB
01_random_17.txt AC 8 ms 5240 KiB
01_random_18.txt AC 5 ms 5200 KiB
01_random_19.txt AC 10 ms 5252 KiB
01_random_20.txt AC 8 ms 5120 KiB
01_random_21.txt AC 6 ms 5100 KiB
01_random_22.txt AC 10 ms 5180 KiB
01_random_23.txt AC 10 ms 5180 KiB
01_random_24.txt AC 9 ms 5176 KiB
01_random_25.txt AC 12 ms 5196 KiB
01_random_26.txt AC 8 ms 5100 KiB
01_random_27.txt AC 9 ms 5260 KiB
01_random_28.txt AC 10 ms 5120 KiB
01_random_29.txt AC 9 ms 5200 KiB
01_random_30.txt AC 8 ms 5180 KiB
01_random_31.txt AC 8 ms 5364 KiB
01_random_32.txt AC 5 ms 5172 KiB
01_random_33.txt AC 12 ms 5040 KiB
01_random_34.txt AC 10 ms 5064 KiB
01_random_35.txt AC 13 ms 5200 KiB
01_random_36.txt AC 11 ms 5172 KiB
01_random_37.txt AC 9 ms 5260 KiB
01_random_38.txt AC 9 ms 5172 KiB
01_random_39.txt AC 9 ms 5064 KiB
01_random_40.txt AC 6 ms 5236 KiB
01_random_41.txt AC 6 ms 4828 KiB
01_random_42.txt AC 9 ms 4940 KiB
01_random_43.txt AC 3 ms 3932 KiB
01_random_44.txt AC 5 ms 4660 KiB
01_random_45.txt AC 3 ms 3756 KiB
01_random_46.txt AC 7 ms 4864 KiB
01_random_47.txt AC 5 ms 4356 KiB
01_random_48.txt AC 2 ms 3932 KiB
01_random_49.txt AC 8 ms 4556 KiB
01_random_50.txt AC 6 ms 4920 KiB
01_random_51.txt AC 13 ms 5176 KiB
01_random_52.txt AC 5 ms 5172 KiB
01_random_53.txt AC 1 ms 3564 KiB
01_random_54.txt AC 1 ms 3580 KiB
01_random_55.txt AC 1 ms 3544 KiB