Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
821 B
2
Indexable
Never
#include <bits/stdc++.h>
using namespace std;
int main() {
    freopen("prefix.in", "r", stdin);
    freopen("prefix.out", "w", stdout);
    string s[100000];
    int n, k;
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }
    for (int i = 0; i < s[k - 1].size(); i++) {
        bool flag = true;
        for (int j = 0; j < n; j++) {
            if (j == k - 1) continue;
            bool now = true;
            for (int t = 0; t <= i; t++) {
                if (s[k - 1][t] != s[j][t]) {
                    now = false;
                    break;
                }
            }
            if (now) {
                flag = false;
                break;
            }
        }
        if (flag) {
            cout << i + 1 << endl;
            return 0;
        }
    }
    return 0;
}