Submission #257061

# Submission time Handle Problem Language Result Execution time Memory
257061 2020-08-03T15:07:00 Z zoooma13 Necklace (Subtask 1-3) (BOI19_necklace1) C++14
0 / 85
26 ms 35584 KB
#include <bits/stdc++.h>
using namespace std;

#define MAX_N 3003

int n ,m;
string s ,t;

int com[MAX_N][MAX_N];
int go(int i ,int j){
    if(i == n || j == m)
        return 0;
    int&ret = com[i][j];
    if(~ret)
        return ret;
    go(i+1 ,j);
    go(i ,j+1);
    if(s[i] == t[j])
        return ret = 1 + go(i+1 ,j+1);
    return ret = 0;
}

int main()
{
    cin >> s >> t; n = s.size() ,m = t.size();
    memset(com ,-1 ,sizeof com);
    go(0 ,0);
    pair<int ,pair <int ,int>> ans;
    for(int i=0; i<n; i++)
    for(int j=0; j<m; j++)
        ans = max(ans ,make_pair(com[i][j] ,make_pair(i ,j)));
    reverse(t.begin() ,t.end());
    memset(com ,-1 ,sizeof com);
    go(0 ,0);
    for(int i=0; i<n; i++)
    for(int j=0; j<m; j++)
        ans = max(ans ,make_pair(com[i][j] ,make_pair(i ,n-j-com[i][j]+1)));
    cout << ans.first << endl;
    cout << ans.second.first << ' ' << ans.second.second << endl;
}
# Verdict Execution time Memory Grader output
1 Incorrect 26 ms 35584 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 26 ms 35584 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 26 ms 35584 KB Output isn't correct
2 Halted 0 ms 0 KB -