QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#75879 | #5460. Sum of Numbers | XKError | Compile Error | / | / | C++14 | 1.5kb | 2023-02-06 15:33:52 | 2023-02-06 15:33:53 |
Judging History
你现在查看的是最新测评结果
- [2023-08-10 23:21:45]
- System Update: QOJ starts to keep a history of the judgings of all the submissions.
- [2023-02-06 15:33:53]
- 评测
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2023-02-06 15:33:52]
- 提交
answer
#include <bits/stdc++.h>
#define maxn 200005
using namespace std;
int T;
int n, k;
int lim;
char s[maxn];
struct bg{
int n;
int a[maxn];
void clear() {
for (int i = 1; i <= n; i++) a[i] = 0;
n = 0;
}
bg operator +(bg b) {
b.n = max(b.n, n) + 1;
for (int i = 1; i <= b.n; i++) {
b.a[i] += a[i];
b.a[i + 1] += b.a[i] / 10;
b.a[i] %= 10;
}
while (b.n && b.a[b.n] == 0) --b.n;
return b;
}
bool operator <(const bg b) const {
if (n < b.n) return 1;
for (int i = n; i; i--) if (a[i] != b.a[i]) return a[i] < b.a[i];
return 0;
}
void deb() {
for (int i = n; i; i--) printf("%d", a[i]);
puts("");
}
}a[10], ans;
bg get(int l, int r) {
bg res;
res.clear();
for (int i = l; i <= r; i++) {
res.a[++res.n] = s[i] - '0';
}
reverse(res.a + 1, res.a + res.n + 1);
return res;
}
void dfs(int i, int j) {
// cout<<i<<" "<<j<<" "<<endl;
// a[j].deb();
if (n - i + 1 > j * lim) return;
if (ans < a[j].n) return;
if (j == 0) return(void)(ans = min(ans, a[j]));
for (int x = lim; x > lim - k; --x) {
if (n - i - x + 1 > (j - 1) * lim) continue;
if (i + x - 1 > n) continue;
a[j - 1] = a[j] + get(i, i + x - 1);
dfs(i + x, j - 1);
}
}
int main() {
scanf("%d", &T);
while (T--) {
scanf("%d%d%s", &n, &k, s + 1);
++k;
lim = (n + k - 1) / k + 1;
// ans = get(1, 4) + get(5, 8);
// cout<<"@"<<k<<endl;
ans.clear();
ans.n = 1e9;
dfs(1, k);
ans.deb();
}
return 0;
}
詳細信息
answer.code: In function ‘void dfs(int, int)’: answer.code:59:17: error: no match for ‘operator<’ (operand types are ‘bg’ and ‘int’) 59 | if (ans < a[j].n) return; | ~~~ ^ ~~~~~~ | | | | bg int answer.code:33:14: note: candidate: ‘bool bg::operator<(bg) const’ 33 | bool operator <(const bg b) const { | ^~~~~~~~ answer.code:33:34: note: no known conversion for argument 1 from ‘int’ to ‘bg’ 33 | bool operator <(const bg b) const { | ~~~~~~~~~^ In file included from /usr/include/c++/11/regex:63, from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:110, from answer.code:1: /usr/include/c++/11/bits/regex.h:1077:5: note: candidate: ‘template<class _BiIter> bool std::__cxx11::operator<(const std::__cxx11::sub_match<_BiIter>&, const std::__cxx11::sub_match<_BiIter>&)’ 1077 | operator<(const sub_match<_BiIter>& __lhs, const sub_match<_BiIter>& __rhs) | ^~~~~~~~ /usr/include/c++/11/bits/regex.h:1077:5: note: template argument deduction/substitution failed: answer.code:59:24: note: ‘bg’ is not derived from ‘const std::__cxx11::sub_match<_BiIter>’ 59 | if (ans < a[j].n) return; | ^ In file included from /usr/include/c++/11/regex:63, from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:110, from answer.code:1: /usr/include/c++/11/bits/regex.h:1158:5: note: candidate: ‘template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator<(std::__cxx11::__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&, const std::__cxx11::sub_match<_BiIter>&)’ 1158 | operator<(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/11/bits/regex.h:1158:5: note: template argument deduction/substitution failed: answer.code:59:24: note: ‘bg’ is not derived from ‘std::__cxx11::__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>’ 59 | if (ans < a[j].n) return; | ^ In file included from /usr/include/c++/11/regex:63, from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:110, from answer.code:1: /usr/include/c++/11/bits/regex.h:1251:5: note: candidate: ‘template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator<(const std::__cxx11::sub_match<_BiIter>&, std::__cxx11::__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&)’ 1251 | operator<(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/11/bits/regex.h:1251:5: note: template argument deduction/substitution failed: answer.code:59:24: note: ‘bg’ is not derived from ‘const std::__cxx11::sub_match<_BiIter>’ 59 | if (ans < a[j].n) return; | ^ In file included from /usr/include/c++/11/regex:63, from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:110, from answer.code:1: /usr/include/c++/11/bits/regex.h:1325:5: note: candidate: ‘template<class _Bi_iter> bool std::__cxx11::operator<(const typename std::iterator_traits<_Iter>::value_type*, const std::__cxx11::sub_match<_BiIter>&)’ 1325 | operator<(typename iterator_traits<_Bi_iter>::value_type const* __lhs, | ^~~~~~~~ /usr/include/c++/11/bits/regex.h:1325:5: note: template argument deduction/substitution failed: answer.code:59:24: note: mismatched types ‘const std::__cxx11::sub_match<_BiIter>’ and ‘int’ 59 | if (ans < a[j].n) return; | ^ In file included from /usr/include/c++/11/regex:63, from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:110, from answer.code:1: /usr/include/c++/11/bits/regex.h:1419:5: note: candidate: ‘template<class _Bi_iter> bool std::__cxx11::operator<(const std::__cxx11::sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type*)’ 1419 | operator<(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/11/bits/regex.h:1419:5: note: template argument deduction/substitution failed: answer.code:59:24: note: ‘bg’ is not derived from ‘const std::__cxx11::sub_match<_BiIter>’ 59 | if (ans < a[j].n) return; | ^ In file included from /usr/include/c++/11/regex:63, from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:110, from answer.code:1: /usr/include/c++/11/bits/regex.h:1494:5: note: candidate: ‘template<class _Bi_iter> bool std::__cxx11::operator<(const typename std::iterator_traits<_Iter>::value_type&, const std::__cxx11::sub_match<_BiIter>&)’ 1494 | operator<(typename iterator_traits<_Bi_iter>::value_type const& __lhs, | ^~~~~~~~ /usr/include/c++/11/bits/regex.h:1494:5: note: template argument deduction/substitution failed: answer.code:5...