Submission #525801

# Submission time Handle Problem Language Result Execution time Memory
525801 2022-02-12T23:01:09 Z ali22413836 Necklace (Subtask 1-3) (BOI19_necklace1) C++14
5 / 85
1500 ms 209544 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 + 1 ; 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 12624 KB Output is correct
2 Correct 133 ms 11428 KB Output is correct
3 Partially correct 52 ms 3808 KB Output is partially correct
4 Correct 143 ms 15324 KB Output is correct
5 Correct 151 ms 23152 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 114 ms 12624 KB Output is correct
2 Correct 133 ms 11428 KB Output is correct
3 Partially correct 52 ms 3808 KB Output is partially correct
4 Correct 143 ms 15324 KB Output is correct
5 Correct 151 ms 23152 KB Output is correct
6 Execution timed out 1598 ms 209544 KB Time limit exceeded
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 114 ms 12624 KB Output is correct
2 Correct 133 ms 11428 KB Output is correct
3 Partially correct 52 ms 3808 KB Output is partially correct
4 Correct 143 ms 15324 KB Output is correct
5 Correct 151 ms 23152 KB Output is correct
6 Execution timed out 1598 ms 209544 KB Time limit exceeded
7 Halted 0 ms 0 KB -