답안 #525808

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
525808 2022-02-12T23:09:11 Z ali22413836 Necklace (Subtask 1-3) (BOI19_necklace1) C++17
5 / 85
1500 ms 223320 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 = i ;
            }
        }
    }
    cout << ans << " " << ans1 << " " << ans2 << endl ;
    return 0 ;
}
# 결과 실행 시간 메모리 Grader output
1 Partially correct 111 ms 12480 KB Output is partially correct
2 Partially correct 120 ms 11340 KB Output is partially correct
3 Partially correct 46 ms 3624 KB Output is partially correct
4 Partially correct 136 ms 14860 KB Output is partially correct
5 Correct 147 ms 22432 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 111 ms 12480 KB Output is partially correct
2 Partially correct 120 ms 11340 KB Output is partially correct
3 Partially correct 46 ms 3624 KB Output is partially correct
4 Partially correct 136 ms 14860 KB Output is partially correct
5 Correct 147 ms 22432 KB Output is correct
6 Execution timed out 1603 ms 223320 KB Time limit exceeded
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Partially correct 111 ms 12480 KB Output is partially correct
2 Partially correct 120 ms 11340 KB Output is partially correct
3 Partially correct 46 ms 3624 KB Output is partially correct
4 Partially correct 136 ms 14860 KB Output is partially correct
5 Correct 147 ms 22432 KB Output is correct
6 Execution timed out 1603 ms 223320 KB Time limit exceeded
7 Halted 0 ms 0 KB -