提出 #74661163


ソースコード 拡げる

#include<bits/extc++.h>

#pragma GCC optimize("O3","unroll-loops")
#pragma GCC target("avx,avx2")

#include<iostream>
#include<queue>
#include<vector>
#include<cmath>
#include<map>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

#define coutc "\033[48;5;196m\033[38;5;15m"
#define endc "\033[0m"
#define M(_1, _2, _3, _4, NAME, ...) NAME
#define rep(...) \
  M(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rep4(_, x, n, s) \
  for (int _ = x; (s < 0) ? _ > n : _ < n; _ += s)
#define rep3(_, x, n) rep4(_, x, n, (x < n ? 1 : -1))
#define rep2(_, n) rep3(_, 0, n)
#define rep1(n) rep2(i, n)

#define FOR(i, a, b) for (int i=a; i<b; i++)
#define F0R(i, a) for (int i=0; i<a; i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) a*b/gcd(a,b)

#define mp make_pair
// #define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define endl "\n"

// #define cin fin
// #define cout fout

// ifstream fin("word.in");
// ofstream fout("word.out");

const int inf = INT_MAX;
const int MOD = 1000000007;
double PI = 4*atan(1);

#ifdef DEBUG
string to_string(char c) { return string({c}); }
// 7
template<class... Ts>
ostream& operator<<(ostream& o, tuple<Ts...> t) {
  string s = "(";
  apply([&](auto&&... r) {
    ((s += to_string(r) + ", "), ...); }, t);
  return o << s.substr(0, len(s) - 2) + ")";
}
// 3
ostream& operator<<(ostream &o, pair<auto, auto> p) {
  return o << "(" << p.fi << ", " << p.se << ")";
}
// 7
template<class C, class T = typename C::value_type,
typename std::enable_if<!std::is_same<C, std::string>
::value>::type* = nullptr>
ostream& operator<<(ostream &o, C c) {
  for (auto e : c) o << setw(7) << right << e;
  return o << endc << endl << coutc;
}
// 7
void debug(const auto &e, const auto &... r) {
  cout << coutc << e;
  ((cout << " " << r), ..., (cout << endc << endl));
}
#else
#define debug(...)
#endif

map<string,int> mon;
map<int,string> inp;

void _main(int tc) {
    string s, t;
    cin >> s >> t;
    int n = (int)s.size(), m = (int)t.size();
    vector<array<int, 26>> nxt(n + 2);
    int c = 0;
    while (c < 26) {
        nxt[n][c] = n;
        nxt[n + 1][c] = n;
        c++;
    }
    int i = n - 1;
    while (i >= 0) {
        nxt[i] = nxt[i + 1];
        nxt[i][s[i] - 'a'] = i;
        i--;
    }
    ll ans = 0;
    i = 0;
    while (i < n) {
        int p = i;
        int j = 0;
        while (j < m) {
            if (p >= n) break;
            p = nxt[p][t[j] - 'a'];
            if (p == n) break;
            p++;
            j++;
        }
        if (j < m) ans += n - i;
        else {
            int e = p - 1;
            ans += e - i;
        }
        i++;
    }
    cout << ans << endl;
}
// 5
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  _main(0), exit(0);
  int tc; cin >> tc; rep(i, tc) _main(i + 1);
}

提出情報

提出日時
問題 D - No-Subsequence Substring
ユーザ zaahir
言語 C++23 (GCC 15.2.0)
得点 400
コード長 3296 Byte
結果 AC
実行時間 35 ms
メモリ 24140 KiB

コンパイルエラー

./Main.cpp: In function 'void _main(int)':
./Main.cpp:92:16: warning: unused parameter 'tc' [-Wunused-parameter]
   92 | void _main(int tc) {
      |            ~~~~^~

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 400 / 400
結果
AC × 3
AC × 56
セット名 テストケース
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
ケース名 結果 実行時間 メモリ
00_sample_00.txt AC 1 ms 3600 KiB
00_sample_01.txt AC 1 ms 3548 KiB
00_sample_02.txt AC 1 ms 3604 KiB
01_random_03.txt AC 14 ms 16244 KiB
01_random_04.txt AC 18 ms 16800 KiB
01_random_05.txt AC 7 ms 10712 KiB
01_random_06.txt AC 10 ms 10364 KiB
01_random_07.txt AC 9 ms 14032 KiB
01_random_08.txt AC 17 ms 24052 KiB
01_random_09.txt AC 23 ms 24048 KiB
01_random_10.txt AC 18 ms 23960 KiB
01_random_11.txt AC 28 ms 24024 KiB
01_random_12.txt AC 11 ms 24036 KiB
01_random_13.txt AC 11 ms 24052 KiB
01_random_14.txt AC 21 ms 23968 KiB
01_random_15.txt AC 23 ms 23904 KiB
01_random_16.txt AC 28 ms 23904 KiB
01_random_17.txt AC 21 ms 24072 KiB
01_random_18.txt AC 12 ms 24044 KiB
01_random_19.txt AC 30 ms 24088 KiB
01_random_20.txt AC 21 ms 24088 KiB
01_random_21.txt AC 12 ms 24092 KiB
01_random_22.txt AC 27 ms 23960 KiB
01_random_23.txt AC 29 ms 24072 KiB
01_random_24.txt AC 25 ms 23968 KiB
01_random_25.txt AC 35 ms 24140 KiB
01_random_26.txt AC 18 ms 24016 KiB
01_random_27.txt AC 23 ms 24092 KiB
01_random_28.txt AC 26 ms 24036 KiB
01_random_29.txt AC 21 ms 23996 KiB
01_random_30.txt AC 18 ms 24036 KiB
01_random_31.txt AC 17 ms 24024 KiB
01_random_32.txt AC 10 ms 23904 KiB
01_random_33.txt AC 26 ms 24048 KiB
01_random_34.txt AC 21 ms 24012 KiB
01_random_35.txt AC 30 ms 24024 KiB
01_random_36.txt AC 26 ms 23904 KiB
01_random_37.txt AC 19 ms 24052 KiB
01_random_38.txt AC 19 ms 24080 KiB
01_random_39.txt AC 20 ms 23904 KiB
01_random_40.txt AC 16 ms 21896 KiB
01_random_41.txt AC 24 ms 19824 KiB
01_random_42.txt AC 23 ms 21072 KiB
01_random_43.txt AC 6 ms 9716 KiB
01_random_44.txt AC 16 ms 18440 KiB
01_random_45.txt AC 5 ms 7184 KiB
01_random_46.txt AC 24 ms 21124 KiB
01_random_47.txt AC 14 ms 13168 KiB
01_random_48.txt AC 4 ms 9696 KiB
01_random_49.txt AC 17 ms 16864 KiB
01_random_50.txt AC 12 ms 20464 KiB
01_random_51.txt AC 32 ms 24044 KiB
01_random_52.txt AC 10 ms 24024 KiB
01_random_53.txt AC 1 ms 3472 KiB
01_random_54.txt AC 1 ms 3572 KiB
01_random_55.txt AC 1 ms 3672 KiB