結果

問題 No.1909 Detect from Substrings
ユーザー otoshigootoshigo
提出日時 2022-04-23 15:59:48
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,647 bytes
コンパイル時間 2,315 ms
コンパイル使用メモリ 204,848 KB
実行使用メモリ 11,512 KB
最終ジャッジ日時 2023-09-07 08:45:47
合計ジャッジ時間 7,108 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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);
        }
    }
    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+1,m){
                if (S[j][j] != t[j+1]){
                    f = false;
                    break;
                }
            }
        }
        if (f) ans++;
    }
    cout << ans << endl;
}
0