답안 #1021945

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1021945 2024-07-13T08:03:55 Z Almonther Necklace (Subtask 1-3) (BOI19_necklace1) C++
0 / 85
348 ms 460 KB
#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){
    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++){
            if(i+k-1>=s.size()) break;
            for(int j=0;j<t.size();j++){
                if(j+k-1>=t.size()) break;
                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

necklace.cpp: In function 'bool canconvert(std::string, std::string)':
necklace.cpp:11:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |     for(int i=0;i<=s.size();i++){
      |                 ~^~~~~~~~~~
necklace.cpp: In function 'void solve()':
necklace.cpp:26:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |         for(int i=0;i<s.size();i++){
      |                     ~^~~~~~~~~
necklace.cpp:27:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |             if(i+k-1>=s.size()) break;
      |                ~~~~~^~~~~~~~~~
necklace.cpp:28:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |             for(int j=0;j<t.size();j++){
      |                         ~^~~~~~~~~
necklace.cpp:29:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |                 if(j+k-1>=t.size()) break;
      |                    ~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 23 ms 348 KB Output is correct
2 Correct 5 ms 460 KB Output is correct
3 Correct 240 ms 432 KB Output is correct
4 Incorrect 348 ms 428 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 23 ms 348 KB Output is correct
2 Correct 5 ms 460 KB Output is correct
3 Correct 240 ms 432 KB Output is correct
4 Incorrect 348 ms 428 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 23 ms 348 KB Output is correct
2 Correct 5 ms 460 KB Output is correct
3 Correct 240 ms 432 KB Output is correct
4 Incorrect 348 ms 428 KB Output isn't correct
5 Halted 0 ms 0 KB -