Submission #1024435

#TimeUsernameProblemLanguageResultExecution timeMemory
1024435ezzzayNecklace (Subtask 1-3) (BOI19_necklace1)C++14
25 / 85
1583 ms7916 KiB
#include<bits/stdc++.h> using namespace std; #define int long long #define ff first #define ss second #define pb push_back bool check(string s, string t){ if(s==t)return 1; string h; int n=s.size(); for(int i=1;i<s.size();i++){ int r=n-i; if(s.substr(0,i)==t.substr(n-i,i) and s.substr(n-r,r)==t.substr(0,r) )return 1; } return 0; } signed main(){ string a,b; cin>>a>>b; vector<pair<int,pair<int,int>>>v; for(int l=0;l<a.size();l++){ for(int r=l;r<a.size();r++){ for(int x=0;x<b.size();x++){ int d=r-l; int y=x+d; if(y>=b.size())continue; string s=a.substr(l,d+1); string t=a.substr(l+1,d); reverse(t.begin(),t.end()); t=a[l]+t; if(check(s,b.substr(x,d+1)) or check(t,b.substr(x,d+1))){ v.pb({-d-1,{l,x}}); } } } } sort(v.begin(),v.end()); cout<<-v[0].ff<<endl; cout<<v[0].ss.ff<<" "<<v[0].ss.ss; }

Compilation message (stderr)

necklace.cpp: In function 'bool check(std::string, std::string)':
necklace.cpp:11:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |     for(int i=1;i<s.size();i++){
      |                 ~^~~~~~~~~
necklace.cpp: In function 'int main()':
necklace.cpp:21:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |     for(int l=0;l<a.size();l++){
      |                 ~^~~~~~~~~
necklace.cpp:22:22: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |         for(int r=l;r<a.size();r++){
      |                     ~^~~~~~~~~
necklace.cpp:23:26: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |             for(int x=0;x<b.size();x++){
      |                         ~^~~~~~~~~
necklace.cpp:26:21: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |                 if(y>=b.size())continue;
      |                    ~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...