답안 #1097882

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1097882 2024-10-08T13:58:40 Z Alihan_8 Palindrome-Free Numbers (BOI13_numbers) C++17
72.5 / 100
1 ms 600 KB
#include <bits/stdc++.h>

using namespace std;

using i64 = long long;

void print(__int128 x){
	if ( x == 0 ) return;
	
	print(x / 10);
	cout << (int)(x % 10);
}

signed main(){
	i64 a, b; cin >> a >> b;
	
	auto f = [&](i64 x) -> __int128{
		if ( x < 0 ) return 0;
		
		string s = to_string(x);
		int n = s.size();
		
		for ( auto &x: s ) x -= '0';
		
		__int128 dp[n][11][11][2]{};
		
		for ( int j = 0; j <= s[0]; j++ ){
			dp[0][10][j][j < s[0]] = 1;
		}
		
		for ( int i = 1; i < n; i++ ){
			for ( int j = 0; j <= 10; j++ ){
				for ( int k = 0; k <= 10; k++ ){
					for ( int c = 0; c <= 9; c++ ){
						if ( c == k || c == j ) continue;
						
						for ( auto l: {0, 1} ){
							if ( !l && c > s[i] ) continue;
							
							int nxt = l || (c < s[i]);
							
							dp[i][k][c][nxt] += dp[i - 1][j][k][l];
						}
					}
				}
			}
		}
		
		i64 cnt = 0;
		
		for ( int x = 0; x <= 10; x++ ){
			for ( int y = 0; y <= 10; y++ ){
				for ( auto f: {0, 1} ){
					cnt += dp[n - 1][x][y][f];
				}
			}
		}
		
		return cnt;
	};
	
	__int128 t = f(b) - f(a - 1);
	
	if ( t == 0 ) cout << "0";
	else print(t);
	
	cout << endl;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Correct 1 ms 348 KB Output is correct
4 Incorrect 0 ms 348 KB Output isn't correct
5 Incorrect 0 ms 348 KB Output isn't correct
6 Incorrect 0 ms 348 KB Output isn't correct
7 Incorrect 0 ms 348 KB Output isn't correct
8 Incorrect 0 ms 348 KB Output isn't correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 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 Incorrect 0 ms 348 KB Output isn't correct
15 Incorrect 1 ms 348 KB Output isn't 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 348 KB Output is correct
20 Incorrect 1 ms 344 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Incorrect 1 ms 600 KB Output isn't correct
6 Correct 1 ms 348 KB Output is correct
7 Incorrect 0 ms 348 KB Output isn't correct
8 Incorrect 0 ms 348 KB Output isn't correct
9 Incorrect 0 ms 348 KB Output isn't correct
10 Incorrect 0 ms 348 KB Output isn't correct
11 Correct 0 ms 348 KB Output is correct
12 Incorrect 0 ms 348 KB Output isn't correct
13 Incorrect 0 ms 348 KB Output isn't correct
14 Incorrect 0 ms 348 KB Output isn't correct
15 Incorrect 0 ms 348 KB Output isn't 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 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 1 ms 344 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 1 ms 348 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
39 Correct 0 ms 344 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 1 ms 348 KB Output is correct
44 Correct 0 ms 348 KB Output is correct
45 Correct 1 ms 348 KB Output is correct