Submission #1021928

#TimeUsernameProblemLanguageResultExecution timeMemory
1021928AlmontherNecklace (Subtask 1-3) (BOI19_necklace1)C++98
0 / 85
66 ms436 KiB
#include <bits/stdc++.h> #define suiii ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); #define ll long long #define co cout<< //#pragma GCC optimize("O3,Ofast,unroll-loops") //#pragma GCC target("avx2,sse3,sse4,avx") using namespace std; //stuff bool canconvert(string s,string t){ string check=s,check1=t; if(s==t) return 1; sort(check.begin(),check.end()); sort(check1.begin(),check1.end()); if(check!=check1) return 0; for(int i=0;i<s.size();i++){ s.push_back(s[0]); s.erase(s.begin()); if(s==t) return 1; reverse(s.begin(),s.end()); if(s==t) return 1; reverse(s.begin(),s.end()); } return 0; } string s,t; void solve(){ cin>>s>>t; if(s.size()>t.size()) swap(s,t); for(int k=s.size();k>0;k--){ for(int i=0;i<s.size();i++){ for(int j=0;j<t.size();j++){ if(canconvert(s.substr(i,k),t.substr(j,k))==1){ co k<<'\n'<<i<<' '<<j; return; } } } } } int main() { suiii int tt=1; // cin>>tt; while(tt--){ solve(); } return 0; }

Compilation message (stderr)

necklace.cpp: In function 'bool canconvert(std::string, std::string)':
necklace.cpp:16:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |     for(int i=0;i<s.size();i++){
      |                 ~^~~~~~~~~
necklace.cpp: In function 'void solve()':
necklace.cpp:31:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |         for(int i=0;i<s.size();i++){
      |                     ~^~~~~~~~~
necklace.cpp:32:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |             for(int j=0;j<t.size();j++){
      |                         ~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...