# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
144664 | 2019-08-17T10:47:19 Z | miguel | Palindrome-Free Numbers (BOI13_numbers) | C++14 | 6 ms | 488 KB |
/* ░░░░░░░░░░░░░░░░▄▄█▀▀██▄▄░░░░░░░ ░░░░░░░░░░░░░▄█▀▀░░░░░░░▀█░░░░░░ ░░░░░░░░░░░▄▀░░░░░░░░░░░░░█░░░░░ ░░░░░░░░░▄█░░░░░░░░░░░░░░░█░░░░░ ░░░░░░░██▀░░░░░░░▄▄▄░░▄░█▄█▄░░░░ ░░░░░▄▀░░░░░░░░░░████░█▄██░▀▄░░░ ░░░░█▀░░░░░░░░▄▄██▀░░█████░██░░░ ░░░█▀░░░░░░░░░▀█░▀█▀█▀▀▄██▄█▀░░░ ░░░██░░░░░░░░░░█░░█░█░░▀▀▄█▀░░░░ ░░░░█░░░░░█░░░▀█░░░░▄░░░░░▄█░░░░ ░░░░▀█░░░░███▄░█░░░░░░▄▄▄▄█▀█▄░░ ░░░░░▀██░░█▄▀▀██░░░░░░░░▄▄█░░▀▄░ ░░░░░░▀▀█▄░▀▄▄░▄░░░░░░░███▀░░▄██ ░░░░░░░░░▀▀▀███▀█▄░░░░░█▀░▀░░░▀█ ░░░░░░░░░░░░▄▀░░░▀█▄░░░░░▄▄░░▄█▀ ░░░▄▄▄▀▀▀▀▀█▀░░░░░█▄▀▄▄▄▄▄▄█▀▀░░ ░▄█░░░▄██▀░░░░░░░░░█▄░░░░░░░░░░░ █▀▀░▄█░░░░░░░░░░░░░░▀▀█▄░░░░░░░░ █░░░█░░░░░░░░░░░░░░░░░░█▄░░░░░░░ */ #include<bits/stdc++.h> using namespace std; #define pb push_back #define dbg(x) cout << #x << '=' << x << '\n'; #define ll long long #define x first #define y second #define pi pair <int, int> #define vi vector <int> #define L nod<<1 #define R ((nod<<1)|1) #define mp make_pair const ll mod = 1000000007; const ll nmax=1000003; #define int ll int a, b; int dp[20][11][11][2]; int f(int x){ for(int idx=0; idx<20; idx++){ for(int xd1=0; xd1<=10; xd1++){ for(int xd2=0; xd2<=10; xd2++){ for(int eq=0; eq<2; eq++) dp[idx][xd1][xd2][eq]=0; } } } if(x<=9) return x+1; int ans=0; vi v; while(x!=0){ v.pb(x%10); x/=10; } reverse(v.begin(), v.end()); //for(int i: v) cout<<i; cout<<" "; for(int i=0; i<v.size(); i++){ if(i==0){ for(int next=1; next<=9; next++){ if(next>v[i]) break; else dp[i][0][next][(next==v[i])]=1; } continue; } else if(i==1){ for(int xd2=1; xd2<=9; xd2++){ for(int eq=0; eq<2; eq++){ for(int next=0; next<=9; next++){ if(eq && next>v[i]) break; int ctrl=(eq&(next==v[i])); if(next!=xd2) dp[i][xd2][next][ctrl]+=dp[i-1][0][xd2][eq]; } } } continue; } else{ for(int xd1=0; xd1<=9; xd1++){ for(int xd2=0; xd2<=9; xd2++){ for(int eq=0; eq<2; eq++){ for(int next=0; next<=9; next++){ if(eq && next>v[i]) break; int ctrl=(eq&(next==v[i])); if(next!=xd1 && next!=xd2) dp[i][xd2][next][ctrl]+=dp[i-1][xd1][xd2][eq]; } } } } } } //for(int i=0; i<v.size(); i++){ for(int xd1=0; xd1<=9; xd1++){ for(int xd2=0; xd2<=9; xd2++){ for(int eq=0; eq<2; eq++){ ans+=dp[v.size()-1][xd1][xd2][eq]; } //} } } return ans; } int32_t main(){ ios_base :: sync_with_stdio(0); cin.tie(); cout.tie(); cin>>a>>b; a--; cout<<f(b)-f(a); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 376 KB | Output isn't correct |
2 | Incorrect | 2 ms | 376 KB | Output isn't correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Incorrect | 2 ms | 376 KB | Output isn't correct |
5 | Incorrect | 1 ms | 376 KB | Output isn't correct |
6 | Incorrect | 2 ms | 376 KB | Output isn't correct |
7 | Incorrect | 2 ms | 376 KB | Output isn't correct |
8 | Incorrect | 6 ms | 376 KB | Output isn't correct |
9 | Correct | 2 ms | 376 KB | Output is correct |
10 | Correct | 2 ms | 376 KB | Output is correct |
11 | Correct | 2 ms | 376 KB | Output is correct |
12 | Correct | 2 ms | 380 KB | Output is correct |
13 | Correct | 2 ms | 376 KB | Output is correct |
14 | Incorrect | 2 ms | 376 KB | Output isn't correct |
15 | Incorrect | 3 ms | 376 KB | Output isn't correct |
16 | Correct | 3 ms | 376 KB | Output is correct |
17 | Correct | 3 ms | 376 KB | Output is correct |
18 | Correct | 2 ms | 376 KB | Output is correct |
19 | Correct | 3 ms | 376 KB | Output is correct |
20 | Incorrect | 2 ms | 376 KB | Output isn't correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 3 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Incorrect | 2 ms | 376 KB | Output isn't correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Incorrect | 2 ms | 376 KB | Output isn't correct |
8 | Incorrect | 2 ms | 376 KB | Output isn't correct |
9 | Incorrect | 3 ms | 376 KB | Output isn't correct |
10 | Incorrect | 2 ms | 376 KB | Output isn't correct |
11 | Correct | 2 ms | 376 KB | Output is correct |
12 | Incorrect | 2 ms | 376 KB | Output isn't correct |
13 | Incorrect | 2 ms | 376 KB | Output isn't correct |
14 | Incorrect | 2 ms | 376 KB | Output isn't correct |
15 | Incorrect | 2 ms | 376 KB | Output isn't correct |
16 | Correct | 2 ms | 376 KB | Output is correct |
17 | Correct | 2 ms | 376 KB | Output is correct |
18 | Correct | 2 ms | 376 KB | Output is correct |
19 | Correct | 2 ms | 376 KB | Output is correct |
20 | Correct | 2 ms | 376 KB | Output is correct |
21 | Correct | 3 ms | 376 KB | Output is correct |
22 | Correct | 2 ms | 376 KB | Output is correct |
23 | Correct | 2 ms | 380 KB | Output is correct |
24 | Correct | 2 ms | 376 KB | Output is correct |
25 | Correct | 2 ms | 376 KB | Output is correct |
26 | Correct | 2 ms | 376 KB | Output is correct |
27 | Correct | 3 ms | 376 KB | Output is correct |
28 | Correct | 2 ms | 376 KB | Output is correct |
29 | Correct | 2 ms | 376 KB | Output is correct |
30 | Correct | 2 ms | 376 KB | Output is correct |
31 | Correct | 2 ms | 376 KB | Output is correct |
32 | Correct | 2 ms | 376 KB | Output is correct |
33 | Correct | 2 ms | 376 KB | Output is correct |
34 | Correct | 2 ms | 376 KB | Output is correct |
35 | Correct | 3 ms | 376 KB | Output is correct |
36 | Correct | 2 ms | 488 KB | Output is correct |
37 | Correct | 2 ms | 380 KB | Output is correct |
38 | Correct | 2 ms | 376 KB | Output is correct |
39 | Correct | 2 ms | 376 KB | Output is correct |
40 | Correct | 2 ms | 376 KB | Output is correct |
41 | Correct | 2 ms | 376 KB | Output is correct |
42 | Correct | 2 ms | 376 KB | Output is correct |
43 | Correct | 2 ms | 376 KB | Output is correct |
44 | Correct | 4 ms | 476 KB | Output is correct |
45 | Correct | 3 ms | 376 KB | Output is correct |