1273 | 2022-03-29 15:42:19 | FulopMate | Kígyózó szavak | cpp14 | Forditási hiba |
#include <bits/stdc++.h>
using namespace std;
//#define __TEST_CASE_TEXT
#define __TEST_CASE_BEFORE "Case #"
#define __TEST_CASE_AFTER ": "
#define ll long long
#define all(c) (c).begin(), (c).end()
#define MIN(a, b) ((a) = min((a), (b)))
#define MAX(a, b) ((a) = max((a), (b)))
const ll MOD = 1e9+7;
const int abc = 'z'-'a'+1;
vector<ll> v[abc];
string ans;
void p(ll n, int maxh, int last = -2){
if(n == 0){
ans = "";
return;
}
int j = 0;
if(last == -2){
while(v[j][maxh] < n){
n -= v[j][maxh];
j++;
}
} else {
if(last == 0){
j = 1;
} else {
j = last-1;
if(v[j][maxh] < n){
n -= v[j][maxh];
j = last+1;
}
}
}
p(n-1, maxh-1, j);
ans += 'a'+j;
}
void solve(){
int n, m; cin>>n>>m;
for(auto &i: v){i.assign(n+1, 0); i[1] = 1;}
for(int i = 2; i <= n; i++){
v[0][i] = v[1][i-1];
v[abc-1][i] = v[abc-2][i-1];
for(char j = 1; j < abc-1; j++){
v[j][i] = min((ll)1e10, v[j-1][i-1] + v[j+1][i-1]);
}
}
for(int j = 0; j < abc; j++){
for(int i = 2; i <= n; i++){
v[j][i] += v[j][i-1];
MIN(v[j][i], 1e10);
}
}
while(m--){
ll a; cin>>a;
p(a, n);
reverse(all(ans));
cout<<ans<<endl;
}
}
int main(){
ios_base::sync_with_stdio(0); cin.tie(0);
int _t;
_t = 1;
for(int _i = 0; _i < _t; _i++){
#ifdef __TEST_CASE_TEXT
cout<<__TEST_CASE_BEFORE<<_i+1<<__TEST_CASE_AFTER;
#endif
solve();
}
return 0;
}
exit status 1
main.cpp: In function ‘void solve()’:
main.cpp:11:38: error: no matching function for call to ‘min(__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type&, double)’
11 | #define MIN(a, b) ((a) = min((a), (b)))
| ^
main.cpp:60:13: note: in expansion of macro ‘MIN’
60 | MIN(v[j][i], 1e10);
| ^~~
In file included from /usr/include/c++/9/bits/char_traits.h:39,
from /usr/include/c++/9/ios:40,
from /usr/include/c++/9/istream:38,
from /usr/include/c++/9/sstream:38,
from /usr/include/c++/9/complex:45,
from /usr/include/c++/9/ccomplex:39,
from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
from main.cpp:1:
/usr/include/c++/9/bits/stl_algobase.h:198:5: note: candidate: ‘template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)’
198 | min(const _Tp& __...