結果

問題 No.1909 Detect from Substrings
ユーザー otoshigootoshigo
提出日時 2022-04-23 16:04:53
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 6 ms / 2,000 ms
コード長 1,664 bytes
コンパイル時間 1,910 ms
コンパイル使用メモリ 203,328 KB
実行使用メモリ 5,748 KB
最終ジャッジ日時 2023-09-07 08:51:29
合計ジャッジ時間 4,303 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,384 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,384 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 4 ms
4,464 KB
testcase_07 AC 3 ms
4,460 KB
testcase_08 AC 5 ms
5,488 KB
testcase_09 AC 4 ms
5,560 KB
testcase_10 AC 4 ms
4,572 KB
testcase_11 AC 4 ms
4,568 KB
testcase_12 AC 4 ms
4,436 KB
testcase_13 AC 5 ms
5,572 KB
testcase_14 AC 4 ms
5,664 KB
testcase_15 AC 5 ms
5,648 KB
testcase_16 AC 4 ms
4,692 KB
testcase_17 AC 3 ms
4,388 KB
testcase_18 AC 4 ms
4,380 KB
testcase_19 AC 3 ms
4,476 KB
testcase_20 AC 3 ms
4,480 KB
testcase_21 AC 4 ms
5,620 KB
testcase_22 AC 5 ms
5,640 KB
testcase_23 AC 4 ms
4,612 KB
testcase_24 AC 4 ms
4,824 KB
testcase_25 AC 4 ms
4,488 KB
testcase_26 AC 5 ms
5,660 KB
testcase_27 AC 5 ms
5,584 KB
testcase_28 AC 5 ms
5,576 KB
testcase_29 AC 5 ms
5,696 KB
testcase_30 AC 5 ms
5,568 KB
testcase_31 AC 4 ms
5,584 KB
testcase_32 AC 6 ms
5,748 KB
testcase_33 AC 5 ms
5,580 KB
testcase_34 AC 5 ms
5,520 KB
testcase_35 AC 5 ms
5,580 KB
testcase_36 AC 6 ms
5,580 KB
testcase_37 AC 5 ms
5,528 KB
testcase_38 AC 6 ms
5,528 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/modint>
using namespace std;
using namespace atcoder;
using ll = long long;
using mint =  modint998244353;
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define rep2(i,a,b) for (int i = a; i < b; i++)
#define rrep2(i,a,b) for (int i = a-1; i >= b; i--)
#define rep3(i,a,b,c) for (int i = a; i < b; i+=c)
#define rrep3(i,a,b,c) for (int i = a-1; i >= b; i-=c)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
template<class T> bool chmax(T &a, T b){if (a < b){a = b;return true;} else return false;}
template<class T> bool chmin(T &a, T b){if (a > b){a = b;return true;} else return false;}
template<class T> T power(T x, ll y){if (y == 0) return 1;T p = pow(x,y/2);if (y%2 == 0) return p*p;else return p*p*x;}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,m; cin >> n >> m;
    vector<string> S(n), T(2);
    rep(i,n) cin >> S[i];
    rep(i,m){
        if (S[0][i] != S[1][i]){
            T[0] = S[0].substr(0,i+1) + S[1].substr(i,m-i);
            T[1] = S[1].substr(0,i+1) + S[0].substr(i,m-i);
            break;
        }
    }
    int ans = 0;
    rep(i,2){
        string t = T[i];
        bool f = true;
        rep(j,n){
            int id = m;
            rep(k,m){
                if (S[j][k] != t[k]){
                    id = k;
                    break;
                }
            }
            rep2(k,id,m){
                if (S[j][k] != t[k+1]){
                    f = false;
                    break;
                }
            }
        }
        if (f) ans++;
    }
    cout << ans << endl;
}
0