Submission #915334

# Submission time Handle Problem Language Result Execution time Memory
915334 2024-01-23T17:36:25 Z vjudge1 Bajka (COCI20_bajka) C++17
Compilation error
0 ms 0 KB
#include "bits/stdc++.h"
using namespace std;
string a;
long long Recursi_n(string Actual, string Objetivo, long long Minutos, long long Posici_n){
    if(Actual == Objetivo) return Minutos;
    vector<long long> Posibles;
    if(Minutos == 0) for(long long i = 0; i < a.size(); i++) if(Objetivo[0] == a[i]) Posibles.push_back(Recursi_n(Actual + a[i], Objetivo, Minutos, i));
    else {
        /*for(long long i = 0; i < a.size(); i++){
            if(i != Posici_n){}
                if(i == 0){
                    if(a[i + 1] == Objetivo[Actual.size()]) Posibles.push_back(Actual + a[i + 1], Objetivo, Minutos + 1, Posici_n + 1);
                    for(long long j = 0; j < a.size(); j++){
                        if(j != i and a[j] == a[i]) Posibles.push_back(Actual, Objetivo, Minutos + abs())
                    }
                } else if(i == a.size() - 1) if(a[i + 1] == Objetivo[Actual.size()]) Posibles.push_back(Actual + a[i + 1], Objetivo, Minutos + 1, Posici_n + 1);
                else {
                    
                }
        }*/
        if(Posici_n < a.size() - 1 and a[Posici_n + 1] == Objetivo[Actual.size()]) Posibles.push_back(Actual + a[Posici_n + 1], Objetivo, Minutos + 1, Posici_n + 1);
        if(Posici_n > 0 and a[Posici_n - 1] == Objetivo[Actual.size()]) Posibles.push_back(Actual + a[Posici_n - 1], Objetivo, Minutos + 1, Posici_n - 1);
        for(long long i = 0; i < a.size(); i++) if(i != Posici_n and a[i] == a[Posici_n]) Posibles.push_back(Actual, Objetivo, Minutos + abs(Posici_n - i), i);
    }
    if(Posibles.empty()) return -1;
    else {
        sort(Posibles.begin(), Posibles.end());
        for(long long i = 0; i < Posibles.size(); i++) if(Posibles[i] != -1) return Posibles[i];
    }
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    long long n, m;
    string b;
    cin>>n>>m>>a>>b;
    if(n == 1){
        if(m == 1 and a[0] == b[0]) cout<<0;
        else cout<<-1;
        return 0;
    }
    cout<<Recursi_n("", b, 0, -1);
    return 0;
}

Compilation message

bajka.cpp: In function 'long long int Recursi_n(std::string, std::string, long long int, long long int)':
bajka.cpp:7:45: 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]
    7 |     if(Minutos == 0) for(long long i = 0; i < a.size(); i++) if(Objetivo[0] == a[i]) Posibles.push_back(Recursi_n(Actual + a[i], Objetivo, Minutos, i));
      |                                           ~~^~~~~~~~~~
bajka.cpp:21: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]
   21 |         if(Posici_n < a.size() - 1 and a[Posici_n + 1] == Objetivo[Actual.size()]) Posibles.push_back(Actual + a[Posici_n + 1], Objetivo, Minutos + 1, Posici_n + 1);
      |            ~~~~~~~~~^~~~~~~~~~~~~~
bajka.cpp:21:164: error: no matching function for call to 'std::vector<long long int>::push_back(std::__cxx11::basic_string<char>, std::string&, long long int, long long int)'
   21 |         if(Posici_n < a.size() - 1 and a[Posici_n + 1] == Objetivo[Actual.size()]) Posibles.push_back(Actual + a[Posici_n + 1], Objetivo, Minutos + 1, Posici_n + 1);
      |                                                                                                                                                                    ^
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/functional:62,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from bajka.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:1187:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = long long int; _Alloc = std::allocator<long long int>; std::vector<_Tp, _Alloc>::value_type = long long int]'
 1187 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1187:7: note:   candidate expects 1 argument, 4 provided
/usr/include/c++/10/bits/stl_vector.h:1203:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = long long int; _Alloc = std::allocator<long long int>; std::vector<_Tp, _Alloc>::value_type = long long int]'
 1203 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1203:7: note:   candidate expects 1 argument, 4 provided
bajka.cpp:22:153: error: no matching function for call to 'std::vector<long long int>::push_back(std::__cxx11::basic_string<char>, std::string&, long long int, long long int)'
   22 |         if(Posici_n > 0 and a[Posici_n - 1] == Objetivo[Actual.size()]) Posibles.push_back(Actual + a[Posici_n - 1], Objetivo, Minutos + 1, Posici_n - 1);
      |                                                                                                                                                         ^
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/functional:62,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from bajka.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:1187:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = long long int; _Alloc = std::allocator<long long int>; std::vector<_Tp, _Alloc>::value_type = long long int]'
 1187 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1187:7: note:   candidate expects 1 argument, 4 provided
/usr/include/c++/10/bits/stl_vector.h:1203:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = long long int; _Alloc = std::allocator<long long int>; std::vector<_Tp, _Alloc>::value_type = long long int]'
 1203 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1203:7: note:   candidate expects 1 argument, 4 provided
bajka.cpp:23:32: 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(long long i = 0; i < a.size(); i++) if(i != Posici_n and a[i] == a[Posici_n]) Posibles.push_back(Actual, Objetivo, Minutos + abs(Posici_n - i), i);
      |                              ~~^~~~~~~~~~
bajka.cpp:23:158: error: no matching function for call to 'std::vector<long long int>::push_back(std::string&, std::string&, long long int, long long int&)'
   23 |         for(long long i = 0; i < a.size(); i++) if(i != Posici_n and a[i] == a[Posici_n]) Posibles.push_back(Actual, Objetivo, Minutos + abs(Posici_n - i), i);
      |                                                                                                                                                              ^
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/functional:62,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from bajka.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:1187:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = long long int; _Alloc = std::allocator<long long int>; std::vector<_Tp, _Alloc>::value_type = long long int]'
 1187 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1187:7: note:   candidate expects 1 argument, 4 provided
/usr/include/c++/10/bits/stl_vector.h:1203:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = long long int; _Alloc = std::allocator<long long int>; std::vector<_Tp, _Alloc>::value_type = long long int]'
 1203 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1203:7: note:   candidate expects 1 argument, 4 provided
bajka.cpp:7:7: warning: suggest explicit braces to avoid ambiguous 'else' [-Wdangling-else]
    7 |     if(Minutos == 0) for(long long i = 0; i < a.size(); i++) if(Objetivo[0] == a[i]) Posibles.push_back(Recursi_n(Actual + a[i], Objetivo, Minutos, i));
      |       ^
bajka.cpp:28:32: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |         for(long long i = 0; i < Posibles.size(); i++) if(Posibles[i] != -1) return Posibles[i];
      |                              ~~^~~~~~~~~~~~~~~~~
bajka.cpp:6:23: warning: control reaches end of non-void function [-Wreturn-type]
    6 |     vector<long long> Posibles;
      |                       ^~~~~~~~