Submission #1209456

#TimeUsernameProblemLanguageResultExecution timeMemory
1209456Theo830Necklace (Subtask 1-3) (BOI19_necklace1)C++20
0 / 85
43 ms832 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 int main(void){ string a,b; cin>>a>>b; ll ans = 0; for(ll len = min(a.size(),b.size());len >= 1;len--){ string s = b.substr(0,len); map<string,ll>mp; f(i,0,a.size()-len+1){ string k = a.substr(i,len); f(j,0,len){ char c = k.back(); k.pop_back(); k = c + k; mp[k] = i; } reverse(all(k)); f(j,0,len){ char c = k.back(); k.pop_back(); k = c + k; mp[k] = i; } } f(j,0,b.size()-len+1){ if(mp.count(s)){ cout<<len<<"\n"; cout<<mp[s]<<" "<<j<<"\n"; return 0; } } } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...