結果

問題 No.1694 ZerOne
ユーザー hourenhouren
提出日時 2021-10-01 22:49:53
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,285 bytes
コンパイル時間 1,757 ms
コンパイル使用メモリ 179,568 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-26 21:20:58
合計ジャッジ時間 3,299 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 1 ms
4,376 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 2 ms
4,380 KB
testcase_29 AC 2 ms
4,376 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1000000007;
using P = pair<int,int>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(x) (x).begin(),(x).end()

int main(){
    string s;
    cin >> s;
    int n = s.size();
    vector<vector<vector<int>>> ppct(n/2+1,vector<vector<int>>(n/2+1));
    for(int i=2;i<=n/2;i++){
        int onecnt = 0;
        rep(j,i) onecnt += (s[j] == '1');
        ppct[i][onecnt].push_back(0);
        for(int j=i;j<n;j++){
            onecnt -= (s[j-i] == '1');
            onecnt += (s[j] == '1');
            ppct[i][onecnt].push_back(j-i+1);
        }
    }
    int ans = 1;
    set<P> seen;
    for(int i=2;i<=n/2;i++){
        for(auto vec:ppct[i]){
            int siz = vec.size();
            rep(j,siz-1){
                for(int k=j+1;k<siz;k++){
                    if(vec[k]-vec[j]<i) continue;
                    if(seen.count(make_pair(vec[j]+i-2,vec[k]+i-2))) continue;
                    if(s.substr(vec[j],i)==s.substr(vec[k],i)) continue;
                    ans++;
                    //cout << i << " " << vec[j] << " " << vec[k] << endl;
                    seen.insert(make_pair(vec[j],vec[k]));
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}
0