답안 #525809

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
525809 2022-02-12T23:09:53 Z ali22413836 Necklace (Subtask 1-3) (BOI19_necklace1) C++14
5 / 85
1500 ms 218724 KB
#include <bits/stdc++.h>
#define  endl "\n"
using namespace std ;
typedef long long ll;
typedef long double ld ;
const int N=2e7;
const ll inf=1e18 ;
const ll mod = 1e9 + 7 ;
ll mypower(ll x, ll y){
    if(y == 0) return 1 ;
    if(y == 1) return x ;
    ll ret = mypower(x , y / 2);
    ret = (ret * ret) % mod;
    if(y % 2) ret = ( ret * x ) % mod ;
    return ret ;
}
string s , s2 ;
ll n , m  ;
map < string , ll > mp ;
int main(){
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> s >> s2 ; n = s.size() , m = s.size() ;
    for(int i = 0  ; i < n ; i++){
        for(int j = i ; j < n ; j++){
            for(int q = i ; q <= j ; q++){
                string s3 = "" ;
                for(int k = q ; k <= j ;k++){
                    s3 += s[k] ;
                }
                for(int k = i ; k < q ; k++){
                    s3 += s[k];
                }
                mp[s3] = i + 10 ;
            }
        }
    }
    ll ans = 0 , ans1 , ans2 ;
    for(int i = 0 ; i < m ; i++){
        for(int j = i ; j < m ; j++){
            string s3 = "" ;
            for(int k = i ; k <= j ; k++){
                s3 += s2[k] ;
            }
            if(mp[s3] && ans <= (j - i + 1)){
                ans = j - i + 1 ;
                ans1 = mp[s3] - 10 ;
                ans2 = i ;
            }
        }
    }
    for(int i = m - 1 ; i >= 0 ; i--){
        for(int j = i ; j >= 0 ; j--){
            string s3 = "" ;
            for(int k = j ; k <= i ; k++){
                s3 += s2[k] ;
            }
            if(mp[s3] && ans <= (j - i + 1)){
                ans = j - i + 1 ;
                ans1 = mp[s3] - 10 ;
                ans2 = j ;
            }
        }
    }
    cout << ans << " " << ans1 << " " << ans2 << endl ;
    return 0 ;
}
# 결과 실행 시간 메모리 Grader output
1 Partially correct 126 ms 12488 KB Output is partially correct
2 Partially correct 124 ms 11364 KB Output is partially correct
3 Partially correct 46 ms 3604 KB Output is partially correct
4 Partially correct 135 ms 14732 KB Output is partially correct
5 Correct 157 ms 22420 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 126 ms 12488 KB Output is partially correct
2 Partially correct 124 ms 11364 KB Output is partially correct
3 Partially correct 46 ms 3604 KB Output is partially correct
4 Partially correct 135 ms 14732 KB Output is partially correct
5 Correct 157 ms 22420 KB Output is correct
6 Execution timed out 1599 ms 218724 KB Time limit exceeded
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Partially correct 126 ms 12488 KB Output is partially correct
2 Partially correct 124 ms 11364 KB Output is partially correct
3 Partially correct 46 ms 3604 KB Output is partially correct
4 Partially correct 135 ms 14732 KB Output is partially correct
5 Correct 157 ms 22420 KB Output is correct
6 Execution timed out 1599 ms 218724 KB Time limit exceeded
7 Halted 0 ms 0 KB -