Submission #961767

# Submission time Handle Problem Language Result Execution time Memory
961767 2024-04-12T12:19:02 Z marinaluca Palindrome-Free Numbers (BOI13_numbers) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>

#pragma GCC optimize ("O4")
#pragma GCC optimize ("fast-math")
#pragma GCC optimize ("unroll-loops")

using namespace std;
#define int long long
#define ll long long
#define XX first
#define YY second
#define all (x) begin(x), end(x)
/**
#define cin fin
#define cout fout
ifstream cin ("pfn.in");
ofstream cout ("pfn.out");
**/
typedef double dbl;
typedef long double ldb;
typedef pair <int, int> pii;
typedef vector <int> vii;
typedef pair <double, int> pdi;
vii v;
const int NMAX = 10;
const int VMAX = 1;
const int RMAX = 179;

int dp[2 * NMAX][RMAX + 1][VMAX + 1][VMAX + 1][VMAX + 1];
int constr (int val){
    if (val < 10){
        v.push_back(val);
        return;
    }
    constr (val / 10);
    v.push_back(val % 10);
}

int gigel (int i, int s, int t, int a, int b, int poz, int rez){
    if (v.size() == i)
        return true;
    if (dp[i][s][t][a][b] == -1)
        return dp[i][s][t][a][b];
    int idx = 9, sum = 0;
    if (t == 0)
        idx = v[i];
    for (int in = 0; in < idx; ++ in){
        if (in == rez&& s) continue;
        if (t && in == poz)   continue;
        sum += gigel (i + 1, s + in, a | (in < idx) ,  b | (in > 0) , ,rez , in);
    }
    return dp[i][s][t][a][b] = sum;
}

int solve (int a){
     if (a == -1)
        return 0;
    v.clear();
    constr (a);
    memset (frec, -1, sizeof frec);
    return gigel (0, 0, 0,0,0,0,0);
}
signed main(void){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int x, y;
    cin >> x >> y;
    cout << solve(y) - solve(x - 1);
    return 0 ^ 0;
}

Compilation message

numbers.cpp: In function 'long long int constr(long long int)':
numbers.cpp:33:9: error: return-statement with no value, in function returning 'long long int' [-fpermissive]
   33 |         return;
      |         ^~~~~~
numbers.cpp: In function 'long long int gigel(long long int, long long int, long long int, long long int, long long int, long long int, long long int)':
numbers.cpp:40:18: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   40 |     if (v.size() == i)
      |         ~~~~~~~~~^~~~
numbers.cpp:50:71: error: expected primary-expression before ',' token
   50 |         sum += gigel (i + 1, s + in, a | (in < idx) ,  b | (in > 0) , ,rez , in);
      |                                                                       ^
numbers.cpp: In function 'long long int solve(long long int)':
numbers.cpp:60:13: error: 'frec' was not declared in this scope; did you mean 'free'?
   60 |     memset (frec, -1, sizeof frec);
      |             ^~~~
      |             free
numbers.cpp: In function 'long long int constr(long long int)':
numbers.cpp:36:16: warning: control reaches end of non-void function [-Wreturn-type]
   36 |     v.push_back(val % 10);
      |     ~~~~~~~~~~~^~~~~~~~~~