Submission #1209445

#TimeUsernameProblemLanguageResultExecution timeMemory
1209445Theo830Necklace (Subtask 1-3) (BOI19_necklace1)C++20
25 / 85
1594 ms416 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const ll INF = 1e9+7; const ll MOD = 998244353; typedef pair<ll,ll> ii; #define iii pair<ll,ii> #define f(i,a,b) for(ll i = a;i < b;i++) #define pb push_back #define vll vector<ll> #define F first #define S second #define all(x) (x).begin(), (x).end() ///I hope I will get uprating and don't make mistakes ///I will never stop programming ///sqrt(-1) Love C++ ///Please don't hack me ///@TheofanisOrfanou Theo830 ///Think different approaches (bs,dp,greedy,graphs,shortest paths,mst) ///Stay Calm ///Look for special cases ///Beware of overflow and array bounds ///Think the problem backwards ///Training bool cmp(string a,string b){ ll n = a.size(); f(i,0,n){ char c = b.back(); b.pop_back(); b = c + b; if(a == b){ return true; } } reverse(all(a)); f(i,0,n){ char c = b.back(); b.pop_back(); b = c + b; if(a == b){ return true; } } return false; } int main(void){ string a,b; cin>>a>>b; ll ans = 0; for(ll len = min(a.size(),b.size());len >= 1;len--){ f(i,0,a.size()-len+1){ f(j,0,b.size()-len+1){ if(cmp(a.substr(i,len),b.substr(j,len))){ cout<<len<<"\n"; cout<<i<<" "<<j<<"\n"; return 0; } } } } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...