Submission #525804

# Submission time Handle Problem Language Result Execution time Memory
525804 2022-02-12T23:05:43 Z ali22413836 Necklace (Subtask 1-3) (BOI19_necklace1) C++14
5 / 85
1500 ms 211592 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 = "" , s4 = "" ;
            for(int k = i ; k <= j ; k++){
                s3 += s2[k] ;
            }
            for(int k = j ; k >= i ; k--){
                s4 += s2[k] ;
            }
            if(mp[s3] && ans <= (j - i + 1)){
                ans = j - i + 1 ;
                ans1 = mp[s3] - 10 ;
                ans2 = i ;
            }
            if(mp[s4] && ans <= (j - i + 1)){
                ans = j - i + 1 ;
                ans1 = mp[s4] - 10 ;
                ans2 = i ;
            }
        }
    }
    cout << ans << " " << ans1 << " " << ans2 << endl ;
    return 0 ;
}
# Verdict Execution time Memory Grader output
1 Correct 114 ms 12680 KB Output is correct
2 Correct 121 ms 11444 KB Output is correct
3 Partially correct 47 ms 3816 KB Output is partially correct
4 Correct 131 ms 15308 KB Output is correct
5 Correct 166 ms 23036 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 114 ms 12680 KB Output is correct
2 Correct 121 ms 11444 KB Output is correct
3 Partially correct 47 ms 3816 KB Output is partially correct
4 Correct 131 ms 15308 KB Output is correct
5 Correct 166 ms 23036 KB Output is correct
6 Execution timed out 1600 ms 211592 KB Time limit exceeded
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 114 ms 12680 KB Output is correct
2 Correct 121 ms 11444 KB Output is correct
3 Partially correct 47 ms 3816 KB Output is partially correct
4 Correct 131 ms 15308 KB Output is correct
5 Correct 166 ms 23036 KB Output is correct
6 Execution timed out 1600 ms 211592 KB Time limit exceeded
7 Halted 0 ms 0 KB -