結果

問題 No.1535 五七五
ユーザー Manuel1024Manuel1024
提出日時 2021-06-06 18:33:22
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 281 ms / 2,000 ms
コード長 1,210 bytes
コンパイル時間 726 ms
コンパイル使用メモリ 73,004 KB
実行使用メモリ 24,832 KB
最終ジャッジ日時 2024-11-23 03:07:32
合計ジャッジ時間 3,598 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main(){
int n;
cin >> n;
int a, b, c;
cin >> a >> b >> c;
vector<string> s(n);
for(auto &p: s) cin >> p;
vector<int> lens(n);
for(int i = 0; i < n; i++) lens[i] = s[i].length();
vector<long long int> sum(n+1);
for(int i = 0; i < n; i++){
sum[i+1] = sum[i]+lens[i];
//cerr << sum[i+1] << " ";
}
int ans = 0;
for(int l = 0; l < n; l++){
int l1 = l;
int wa = n+1;
while(wa-l1 > 1){
int wj = (wa+l1)/2;
if(sum[wj]-sum[l] <= a) l1 = wj;
else wa = wj;
}
if(sum[l1]-sum[l] != a) continue;
int l2 = l1;
wa = n+1;
while(wa-l2 > 1){
int wj = (wa+l2)/2;
if(sum[wj]-sum[l1] <= b) l2 = wj;
else wa = wj;
}
if(sum[l2]-sum[l1] != b) continue;
int r = l2;
wa = n+1;
while(wa-r > 1){
int wj = (wa+r)/2;
if(sum[wj]-sum[l2] <= c) r = wj;
else wa = wj;
}
if(sum[r]-sum[l2] == c) ans++;
}
cout << ans << endl;
return 0;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0