제출 #1228780

#제출 시각아이디문제언어결과실행 시간메모리
1228780PlayVoltzPalindrome-Free Numbers (BOI13_numbers)C++20
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;

#define int long long

string s;
int dp[19][11][11][2][2];

int numbers(int digits, int p2, int p1, bool bounded, bool have){
	if (digits==s.size())return have;
	if (dp[digits][p2+1][p1+1][bounded][have]!=-1)return dp[digits][p2+1][p1+1][bounded][have];
	int res=0, end=(bounded?s[digits]-'0':9);
	for (int i=0; i<=end; ++i){
		if (!i&&p1==-1)res+=numbers(digits+1, -1, -1, 0, 0);
		else res+=numbers(digits+1, p1, i, bounded&(i==end), have|(i==p1)|(i==p2));
	}
	return dp[digits][p2+1][p1+1][bounded][have]=res;
}

int ans(int num){
	if (num<0)return 0;
	s = to_string(num);
	memset(dp, -1, sizeof(dp));
	return numbers(0, -1, -1, 1, 0);
}

int32_t main(){
	int a, b;
	cin>>a>>b;
	cout<<(b-a+1)-ans(b)+ans(a-1);
}

컴파일 시 표준 에러 (stderr) 메시지

numbers.cpp: In function 'long long int numbers(long long int, long long int, long long int, bool, bool)':
numbers.cpp:14:37: error: reference to 'numbers' is ambiguous
   14 |                 if (!i&&p1==-1)res+=numbers(digits+1, -1, -1, 0, 0);
      |                                     ^~~~~~~
In file included from /usr/include/c++/11/bits/max_size_type.h:37,
                 from /usr/include/c++/11/bits/ranges_base.h:38,
                 from /usr/include/c++/11/string_view:48,
                 from /usr/include/c++/11/bits/basic_string.h:48,
                 from /usr/include/c++/11/string:55,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from numbers.cpp:1:
/usr/include/c++/11/numbers:48:11: note: candidates are: 'namespace std::numbers { }'
   48 | namespace numbers
      |           ^~~~~~~
numbers.cpp:9:5: note:                 'long long int numbers(long long int, long long int, long long int, bool, bool)'
    9 | int numbers(int digits, int p2, int p1, bool bounded, bool have){
      |     ^~~~~~~
numbers.cpp:15:27: error: reference to 'numbers' is ambiguous
   15 |                 else res+=numbers(digits+1, p1, i, bounded&(i==end), have|(i==p1)|(i==p2));
      |                           ^~~~~~~
In file included from /usr/include/c++/11/bits/max_size_type.h:37,
                 from /usr/include/c++/11/bits/ranges_base.h:38,
                 from /usr/include/c++/11/string_view:48,
                 from /usr/include/c++/11/bits/basic_string.h:48,
                 from /usr/include/c++/11/string:55,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from numbers.cpp:1:
/usr/include/c++/11/numbers:48:11: note: candidates are: 'namespace std::numbers { }'
   48 | namespace numbers
      |           ^~~~~~~
numbers.cpp:9:5: note:                 'long long int numbers(long long int, long long int, long long int, bool, bool)'
    9 | int numbers(int digits, int p2, int p1, bool bounded, bool have){
      |     ^~~~~~~
numbers.cpp: In function 'long long int ans(long long int)':
numbers.cpp:24:16: error: reference to 'numbers' is ambiguous
   24 |         return numbers(0, -1, -1, 1, 0);
      |                ^~~~~~~
In file included from /usr/include/c++/11/bits/max_size_type.h:37,
                 from /usr/include/c++/11/bits/ranges_base.h:38,
                 from /usr/include/c++/11/string_view:48,
                 from /usr/include/c++/11/bits/basic_string.h:48,
                 from /usr/include/c++/11/string:55,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from numbers.cpp:1:
/usr/include/c++/11/numbers:48:11: note: candidates are: 'namespace std::numbers { }'
   48 | namespace numbers
      |           ^~~~~~~
numbers.cpp:9:5: note:                 'long long int numbers(long long int, long long int, long long int, bool, bool)'
    9 | int numbers(int digits, int p2, int p1, bool bounded, bool have){
      |     ^~~~~~~