답안 #961930

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
961930 2024-04-12T18:52:39 Z marinaluca Palindrome-Free Numbers (BOI13_numbers) C++14
100 / 100
1 ms 596 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;**/
vector <int> v;
const int NMAX = 10;
const int VMAX = 1;
const int RMAX = 179;
int x, y;
int dp[20][2][2][2];
void constr (int x){
    if (x < 10){
        v.push_back(x);
        return;
    }
    constr (x / 10);
    v.push_back(x % 10);
}
 
int gigel (int i, int s, int t, int a, int b, int poz){
    if (i == v.size())
        return true;
    if (dp[i][s][t][a] != -1)
        return dp[i][s][t][a];
    int idx = 9, sum = 0;
    if (s == 0)
        idx = v[i];
    for (int in = 0; in <= idx; ++ in){
        if (in == poz && t) continue;
        if (a && in == b)   continue;
        sum += gigel (i + 1, s | (in < idx),  t | (in > 0) , a | t , poz , in);
    }
    return dp[i][s][t][a] = sum;
}
 
int solve (int a){
     if (a == -1)
        return 0;
    v.clear();
    constr (a);
    memset (dp, -1, sizeof dp);
    return gigel (0, 0, 0,0,0,0);
}
signed main(void){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin >> x >> y;
    cout << solve(y) - solve(x - 1);
    return 0 ^ 0;
}

Compilation message

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)':
numbers.cpp:40:11: 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]
   40 |     if (i == v.size())
      |         ~~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 464 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 460 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 460 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 344 KB Output is correct
22 Correct 1 ms 344 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 1 ms 460 KB Output is correct
37 Correct 0 ms 348 KB Output is correct
38 Correct 0 ms 344 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 0 ms 348 KB Output is correct
41 Correct 0 ms 348 KB Output is correct
42 Correct 1 ms 348 KB Output is correct
43 Correct 0 ms 348 KB Output is correct
44 Correct 0 ms 456 KB Output is correct
45 Correct 0 ms 596 KB Output is correct