Submission #874165

# Submission time Handle Problem Language Result Execution time Memory
874165 2023-11-16T11:34:46 Z vjudge1 Necklace (Subtask 1-3) (BOI19_necklace1) C++17
5 / 85
1500 ms 432 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 << " " << r << "\n";
                        return;
                    }
                }
            }
        }
    }

    cout << 0 << "\n";
    cout << 0 << " " << 0 << "\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;
}
# Verdict Execution time Memory Grader output
1 Correct 16 ms 344 KB Output is correct
2 Correct 4 ms 348 KB Output is correct
3 Correct 221 ms 428 KB Output is correct
4 Correct 299 ms 428 KB Output is correct
5 Partially correct 562 ms 432 KB Output is partially correct
# Verdict Execution time Memory Grader output
1 Correct 16 ms 344 KB Output is correct
2 Correct 4 ms 348 KB Output is correct
3 Correct 221 ms 428 KB Output is correct
4 Correct 299 ms 428 KB Output is correct
5 Partially correct 562 ms 432 KB Output is partially correct
6 Execution timed out 1522 ms 352 KB Time limit exceeded
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 16 ms 344 KB Output is correct
2 Correct 4 ms 348 KB Output is correct
3 Correct 221 ms 428 KB Output is correct
4 Correct 299 ms 428 KB Output is correct
5 Partially correct 562 ms 432 KB Output is partially correct
6 Execution timed out 1522 ms 352 KB Time limit exceeded
7 Halted 0 ms 0 KB -