답안 #874162

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
874162 2023-11-16T11:31:16 Z vjudge1 Necklace (Subtask 1-3) (BOI19_necklace1) C++17
0 / 85
16 ms 348 KB
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;

#define ONLINE_JUDGE
void solve() {
    string a, b;
    cin >> a >> b;

    int n = int(a.size()), m = int(b.size());
    for(int len = min(n, m); len >= 1; len--) {
        for(int l = 0; l + len -1 < n; l++) {
            for(int r = 0; r + len -1 < m; r++) {
                for(int k = 0; k < len; k++) {
                    string x = a.substr(l, len);
                    reverse(x.begin(), x.end());

                    //cerr << len << " -> " << x.substr(0, k) << " " << b.substr(r + len - k, k) << " :: " << x.substr(k, len - k) << " " << b.substr(r, len - k) << "\n";
                    if(x.substr(0, k) == b.substr(r + len - k, k) && x.substr(k, len - k) == b.substr(r, len - k)) {
                        cout << len << "\n";
                        cout << l +1 << " " << r +1 << "\n";
                        return;
                    }
                }
            }
        }
    }

    cout << 0 << "\n";
    cout << 1 << " " << 1 << "\n";
    
    return;
}

signed main() {
    #ifndef ONLINE_JUDGE
        freopen(".in", "r", stdin);
        freopen(".out", "w", stdout);
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);

    int t = 1; //cin >> t;
    for(int i = 1; i <= t; i++) {
        solve();
    }

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 16 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 16 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 16 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -