답안 #513723

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
513723 2022-01-17T12:54:01 Z Mahdi Necklace (Subtask 1-3) (BOI19_necklace1) C++17
45 / 85
1500 ms 312 KB
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(v) v.begin(), v.end()
#define F first
#define S second
typedef long long ll;
typedef pair<int, int> pii;
const int N=1e5+5;
string s, t;
int n, m,ans, l, r;

void sol(){
    for(int i=0;i<n;++i){
        for(int j=0;j<m;++j){
            int x=0;
            while(x<n-i && x<m-j && s[i+x]==t[j+x])
                ++x;
            int y=0;
            for(int k=min(n-i-x, j);k>=1;--k){
                bool bl=1;
                for(int o=1;o<=k;++o){
                    if(s[i+x+o-1]!=t[j-k+o-1]){
                        bl=0;
                        break;
                    }
                }
                if(bl){
                    y=k;
                    break;
                }
            }
            if(x+y>ans){
                ans=x+y;
                l=i;
                r=j-y;
            }
        }
    }
}

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin>>s>>t;
    n=s.size();
    m=t.size();
    ans=0;
    sol();
    int x=ans;
    reverse(all(t));
    sol();
    if(ans>x)
        r=m-r-ans;
    cout<<ans<<'\n'<<l<<' '<<r<<'\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 236 KB Output is correct
2 Correct 3 ms 204 KB Output is correct
3 Correct 2 ms 204 KB Output is correct
4 Correct 2 ms 204 KB Output is correct
5 Correct 2 ms 312 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 236 KB Output is correct
2 Correct 3 ms 204 KB Output is correct
3 Correct 2 ms 204 KB Output is correct
4 Correct 2 ms 204 KB Output is correct
5 Correct 2 ms 312 KB Output is correct
6 Correct 565 ms 292 KB Output is correct
7 Correct 465 ms 292 KB Output is correct
8 Correct 188 ms 208 KB Output is correct
9 Correct 185 ms 292 KB Output is correct
10 Correct 57 ms 292 KB Output is correct
11 Correct 58 ms 208 KB Output is correct
12 Correct 379 ms 296 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 236 KB Output is correct
2 Correct 3 ms 204 KB Output is correct
3 Correct 2 ms 204 KB Output is correct
4 Correct 2 ms 204 KB Output is correct
5 Correct 2 ms 312 KB Output is correct
6 Correct 565 ms 292 KB Output is correct
7 Correct 465 ms 292 KB Output is correct
8 Correct 188 ms 208 KB Output is correct
9 Correct 185 ms 292 KB Output is correct
10 Correct 57 ms 292 KB Output is correct
11 Correct 58 ms 208 KB Output is correct
12 Correct 379 ms 296 KB Output is correct
13 Execution timed out 1568 ms 208 KB Time limit exceeded
14 Halted 0 ms 0 KB -