답안 #1024444

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1024444 2024-07-16T05:16:24 Z ezzzay Necklace (Subtask 1-3) (BOI19_necklace1) C++14
25 / 85
1500 ms 7872 KB
#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,d+1);
                reverse(t.begin(),t.end());
                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

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;
      |                    ~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 380 ms 7100 KB Output is correct
2 Correct 415 ms 7872 KB Output is correct
3 Correct 324 ms 1992 KB Output is correct
4 Correct 341 ms 1280 KB Output is correct
5 Correct 435 ms 436 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 380 ms 7100 KB Output is correct
2 Correct 415 ms 7872 KB Output is correct
3 Correct 324 ms 1992 KB Output is correct
4 Correct 341 ms 1280 KB Output is correct
5 Correct 435 ms 436 KB Output is correct
6 Execution timed out 1600 ms 416 KB Time limit exceeded
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 380 ms 7100 KB Output is correct
2 Correct 415 ms 7872 KB Output is correct
3 Correct 324 ms 1992 KB Output is correct
4 Correct 341 ms 1280 KB Output is correct
5 Correct 435 ms 436 KB Output is correct
6 Execution timed out 1600 ms 416 KB Time limit exceeded
7 Halted 0 ms 0 KB -