結果

問題 No.1535 五七五
ユーザー KKT89KKT89
提出日時 2021-06-06 18:34:08
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 64 ms / 2,000 ms
コード長 1,191 bytes
コンパイル時間 2,577 ms
コンパイル使用メモリ 215,236 KB
実行使用メモリ 15,044 KB
最終ジャッジ日時 2023-08-15 00:46:12
合計ジャッジ時間 4,501 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 44 ms
14,972 KB
testcase_05 AC 46 ms
15,044 KB
testcase_06 AC 48 ms
14,936 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 62 ms
14,984 KB
testcase_19 AC 61 ms
14,968 KB
testcase_20 AC 62 ms
14,648 KB
testcase_21 AC 63 ms
14,940 KB
testcase_22 AC 64 ms
14,960 KB
testcase_23 AC 62 ms
14,720 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
    return (ull)rng() % B;
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> b(3);
    for(int i=0;i<3;i++){
        cin >> b[i];
    }
    vector<int> a(n);
    vector<int> sum(n+1);
    for(int i=0;i<n;i++){
        string s; cin >> s;
        a[i]=s.size();
        sum[i+1]=sum[i]+a[i];
    }
    vector<vector<int>> nx(3,vector<int>(n,-1));
    for(int i=0;i<3;i++){
        int k=0;
        for(int j=0;j<n;j++){
            while(k<n and sum[k]-sum[j]<b[i]){
                k++;
            }
            if(sum[k]-sum[j]==b[i]){
                nx[i][j]=k-1;
            }
        }
    }
    int res=0;
    for(int i=0;i<n;i++){
        int j=nx[0][i];
        if(j==-1)continue;
        j++;
        if(j>=n)continue;
        j=nx[1][j];
        if(j==-1)continue;
        j++;
        if(j>=n)continue;
        j=nx[2][j];
        if(j==-1)continue;
        res++;
    }
    cout << res << endl;
}
0