QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#114247 | #6635. Strange Keyboard | jeffqi | Compile Error | / | / | C++23 | 1.9kb | 2023-06-21 17:45:33 | 2023-06-21 17:45:36 |
Judging History
你现在查看的是最新测评结果
- [2023-08-10 23:21:45]
- System Update: QOJ starts to keep a history of the judgings of all the submissions.
- [2023-06-21 17:45:36]
- 评测
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2023-06-21 17:45:33]
- 提交
answer
#include<bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define eb emplace_back
#define pb push_back
#define all(v) v.begin(),v.end()
#define sz(v) ((int)v.size())
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fi first
#define se second
#define umap unordered_map
using namespace std;
namespace qiqi {
const ll inf = 1e18;
struct Trie {
struct Node {
vi ch; ll k;
Node() {
ch.assign(26,-1);
k = inf;
}
};
vector<Node> a;
Trie() {
a.eb();
}
int ins(int x,int c,int k) {
if (a[x].ch[c] == -1) {
a[x].ch[c] = sz(a);
a.eb();
}
x = a[x].ch[c];
a[x].k = min(a[x].k,k);
return x;
}
};
void main() {
int n,m;
cin >> n >> m;
vll c(m,inf); c[0] = 0;
vector<string> s(n);
for (int i = 0; i < n; i++) {
cin >> s[i]; int x = sz(s[i]);
c[x%m] = min(c[x%m],x/m+1);
}
vector<pii> vec;
for (int i = 1; i < m; i++) {
if (c[i] != inf) {
vec.eb(i,c[i]);
}
}
for (auto [d,k]:vec) {
int g = __gcd(d,m);
for (int i = 0; i < g; i++) {
for (int j = 0,x = i,y = (i+d)%m; j < 2*m/g; j++,x = y,y = (y+d)%m) {
c[y] = min(c[y],c[x]+k+(y < x));
}
}
}
Trie trie;
for (int i = 0; i < n; i++) {
int x = sz(s[i]),p = 0;
for (int j = 0; j < x; j++) {
int y = c[(m-(x-j-1)%m)%m]+(x-j-1+m-1)/m+1;
p = trie.ins(p,s[i][j]-'a',y);
}
}
string t; cin >> t;
n = sz(t);
vll f(n+1,inf); f[0] = 0;
for (int i = 0; i < n; i++) {
if (f[i] != inf) {
int p = 0;
for (int j = i; j < n; j++) {
p = trie.a[p].ch[t[j]-'a'];
if (p == -1) {
break;
}
f[j+1] = min(f[j+1],f[i]+trie.a[p].k);
}
}
}
if (f[n] == inf) {
cout << "-1\n";
return;
}
cout << f[n] << '\n';
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int T; cin >> T;
while (T--) qiqi::main();
return 0;
}
Details
answer.code: In member function ‘int qiqi::Trie::ins(int, int, int)’: answer.code:35:37: error: no matching function for call to ‘min(long long int&, int&)’ 35 | a[x].k = min(a[x].k,k); | ~~~^~~~~~~~~~ In file included from /usr/include/c++/11/bits/specfun.h:45, from /usr/include/c++/11/cmath:1927, from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41, from answer.code:1: /usr/include/c++/11/bits/stl_algobase.h:230:5: note: candidate: ‘template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)’ 230 | min(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/11/bits/stl_algobase.h:230:5: note: template argument deduction/substitution failed: answer.code:35:37: note: deduced conflicting types for parameter ‘const _Tp’ (‘long long int’ and ‘int’) 35 | a[x].k = min(a[x].k,k); | ~~~^~~~~~~~~~ In file included from /usr/include/c++/11/bits/specfun.h:45, from /usr/include/c++/11/cmath:1927, from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41, from answer.code:1: /usr/include/c++/11/bits/stl_algobase.h:278:5: note: candidate: ‘template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)’ 278 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/11/bits/stl_algobase.h:278:5: note: template argument deduction/substitution failed: answer.code:35:37: note: deduced conflicting types for parameter ‘const _Tp’ (‘long long int’ and ‘int’) 35 | a[x].k = min(a[x].k,k); | ~~~^~~~~~~~~~ In file included from /usr/include/c++/11/string:52, 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 answer.code:1: /usr/include/c++/11/bits/stl_algo.h:3449:5: note: candidate: ‘template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)’ 3449 | min(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/11/bits/stl_algo.h:3449:5: note: template argument deduction/substitution failed: answer.code:35:37: note: mismatched types ‘std::initializer_list<_Tp>’ and ‘long long int’ 35 | a[x].k = min(a[x].k,k); | ~~~^~~~~~~~~~ In file included from /usr/include/c++/11/string:52, 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 answer.code:1: /usr/include/c++/11/bits/stl_algo.h:3455:5: note: candidate: ‘template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)’ 3455 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/11/bits/stl_algo.h:3455:5: note: template argument deduction/substitution failed: answer.code:35:37: note: mismatched types ‘std::initializer_list<_Tp>’ and ‘long long int’ 35 | a[x].k = min(a[x].k,k); | ~~~^~~~~~~~~~ answer.code: In function ‘void qiqi::main()’: answer.code:46:37: error: no matching function for call to ‘min(__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type&, int)’ 46 | c[x%m] = min(c[x%m],x/m+1); | ~~~^~~~~~~~~~~~~~ In file included from /usr/include/c++/11/bits/specfun.h:45, from /usr/include/c++/11/cmath:1927, from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41, from answer.code:1: /usr/include/c++/11/bits/stl_algobase.h:230:5: note: candidate: ‘template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)’ 230 | min(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/11/bits/stl_algobase.h:230:5: note: template argument deduction/substitution failed: answer.code:46:37: note: deduced conflicting types for parameter ‘const _Tp’ (‘long long int’ and ‘int’) 46 | c[x%m] = min(c[...