結果

問題 No.1909 Detect from Substrings
ユーザー otoshigootoshigo
提出日時 2022-04-22 22:08:03
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,956 bytes
コンパイル時間 2,373 ms
コンパイル使用メモリ 204,768 KB
実行使用メモリ 5,500 KB
最終ジャッジ日時 2023-09-06 08:38:36
合計ジャッジ時間 3,734 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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), V;
    rep(i,n) cin >> S[i];
    rep(i,m){
        if (S[0][i] != S[1][i]){
            rep(j,2){
                string t = S[0].substr(0,i);
                t += S[j][i];
                bool f = true;
                rep2(k,i,m-1){
                    if (S[j][k+1] != S[1-j][k]) f = false;
                    t += S[1-j][k];
                }
                if (f){
                    t += S[1-j][m-1];
                    V.push_back(t);
                }
            }
            break;
        }
    }
    int ans = 0;
    for (auto s:V){
        bool f = true;
        rep(i,n){
            int id = m;
            rep(j,m){
                if (S[i][j] != s[j]){
                    id = j;
                    break;
                }
            }
            rep2(j,id+1,m+1){
                if (S[i][j] != s[j+1]){
                    f = false;
                    break;
                }
            }
            if (!f) break;
        }
        if (f) ans++;
    }
    cout << ans << endl;
}
0