結果

問題 No.515 典型LCP
ユーザー TakatenTakaten
提出日時 2017-05-05 23:39:03
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
OLE  
実行時間 -
コード長 864 bytes
コンパイル時間 1,629 ms
コンパイル使用メモリ 167,748 KB
実行使用メモリ 10,572 KB
最終ジャッジ日時 2023-10-12 10:27:00
合計ジャッジ時間 6,694 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 OLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<string> s(n);
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }
    int m, x, d;
    cin >> m >> x >> d;

    int sum = 0;
    for (int k = 1; k <= m; k++) {
        int i, j;
        i = (x / (n - 1));
        j = (x % (n - 1));
        if (i > j) {
            swap(i, j);
        } else {
            j++;
        }
        x = (x + d) % (n * (n - 1));

        cout << "i: " << i << " j: " << j << " x: " << x << endl;
        cout << s[i].length() << " " << s[j].length() << endl;
        int len = min(s[i].length(), s[j].length());
        for (int l = 0; l < len; l++) {
            if (s[i][l] == s[j][l]) {
                sum++;
            } else {
                break;
            }
        }
    }

    cout << sum << endl;

    return 0;
}
0