QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#534062 | #8340. 3 Sum | training_233# | Compile Error | / | / | C++14 | 3.3kb | 2024-08-26 20:11:01 | 2024-08-26 20:11:02 |
Judging History
你现在查看的是最新测评结果
- [2024-09-20 10:20:30]
- hack成功,自动添加数据
- (/hack/848)
- [2024-08-26 20:11:02]
- 评测
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2024-08-26 20:11:01]
- 提交
answer
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
#include<unordered_map>
using namespace std;
const long long mod=1e18;
int n,m,ans,cnt;
long long base;
string s;
struct num
{
int len;
long long a[1501];
num()
{
len=0;
memset(a,0,sizeof a);
}
inline void init(string s)
{
reverse(s.begin(),s.end());
while(s.length()%18)
s.push_back('0');
len=s.length()/18;
for(int i=len;i>=1;--i)
for(int j=1;j<=18;++j)
{
a[i]=a[i]*10+s.back()-'0';
s.pop_back();
}
}
bool operator <(const num &other) const
{
if(len^other.len)
return len<other.len;
for(int i=len;i>=1;--i)
if(a[i]^other.a[i])
return a[i]<other.a[i];
return 0;
}
bool operator ==(const num &other) const
{
if(len^other.len)
return 0;
for(int i=len;i>=1;--i)
if(a[i]^other.a[i])
return 0;
return 1;
}
}a[501],tmp,M;
unordered_map<num,int> mp;
inline num operator +(const num &x,const num &y)
{
num res;
res.len=max(x.len,y.len);
long long d=0;
for(int i=1;i<=res.len;++i)
{
res.a[i]=d;
if(res.len<=x.len)
res.a[i]+=x.a[i];
if(res.len<=y.len)
res.a[i]+=y.a[i];
d=res.a[i]/mod;
res.a[i]%=mod;
}
while(d)
{
res.a[++res.len]=d;
d=res.a[res.len]/mod;
res.a[res.len]%=mod;
}
return res;
}
inline num operator -(const num &x,const num &y)
{
num res;
res.len=x.len;
long long d=0;
for(int i=1;i<=res.len;++i)
{
res.a[i]=x.a[i]-d;
if(i<=y.len)
res.a[i]-=y.a[i];
d=0;
if(res.a[i]<0)
{
res.a[i]+=mod;
d=mod;
}
}
while(res.len&&!res.a[res.len])
--res.len;
return res;
}
inline num solve(num x)
{
while(!(x<M))
{
if(x==M)
{
x.len=0;
return x;
}
tmp.len=M.len;
for(int i=1;i<tmp.len;++i)
tmp.a[i]=x.a[i];
tmp.a[tmp.len]=x.a[tmp.len]%base;
for(int i=tmp.len;i<=x.len;++i)
x.a[i-tmp.len+1]=x.a[i]/base+x.a[i+1]%base*(mod/base);
x.len-=tmp.len-1;
while(!x.a[x.len])
--x.len;
x=tmp+x;
}
while(x.len&&!x.a[x.len])
--x.len;
return x;
}
inline void init()
{
ios::sync_with_stdio(0);
cin.tie(0);
}
int main()
{
init();
cin>>n>>m;
cnt=m%18;
base=1;
for(int i=1;i<=cnt;++i)
base*=10;
for(int i=1;i<=m;++i)
s.push_back('9');
M.init(s);
for(int i=1;i<=n;++i)
{
cin>>s;
a[i].init(s);
a[i]=solve(a[i]);
}
for(int i=1;i<=n;++i)
for(int j=1;j<=n;++j)
ans+=!solve(a[i]+a[i]+a[j]).len;
for(int i=1;i<=n;++i)
{
for(int j=i+1;j<=n;++j)
{
num res=solve(a[i]+a[j]);
if(mp.count(res))
ans+=mp[res];
}
++mp[solve(M-a[i])];
}
cout<<ans<<'\n';
cout.flush();
return 0;
}
详细
answer.code:53:24: error: use of deleted function ‘std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map() [with _Key = num; _Tp = int; _Hash = std::hash<num>; _Pred = std::equal_to<num>; _Alloc = std::allocator<std::pair<const num, int> >]’ 53 | unordered_map<num,int> mp; | ^~ In file included from /usr/include/c++/13/unordered_map:41, from answer.code:6: /usr/include/c++/13/bits/unordered_map.h:148:7: note: ‘std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map() [with _Key = num; _Tp = int; _Hash = std::hash<num>; _Pred = std::equal_to<num>; _Alloc = std::allocator<std::pair<const num, int> >]’ is implicitly deleted because the default definition would be ill-formed: 148 | unordered_map() = default; | ^~~~~~~~~~~~~ /usr/include/c++/13/bits/unordered_map.h:148:7: error: use of deleted function ‘std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::_Hashtable() [with _Key = num; _Value = std::pair<const num, int>; _Alloc = std::allocator<std::pair<const num, int> >; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<num>; _Hash = std::hash<num>; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _RehashPolicy = std::__detail::_Prime_rehash_policy; _Traits = std::__detail::_Hashtable_traits<true, false, true>]’ In file included from /usr/include/c++/13/bits/unordered_map.h:33: /usr/include/c++/13/bits/hashtable.h:530:7: note: ‘std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::_Hashtable() [with _Key = num; _Value = std::pair<const num, int>; _Alloc = std::allocator<std::pair<const num, int> >; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<num>; _Hash = std::hash<num>; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _RehashPolicy = std::__detail::_Prime_rehash_policy; _Traits = std::__detail::_Hashtable_traits<true, false, true>]’ is implicitly deleted because the default definition would be ill-formed: 530 | _Hashtable() = default; | ^~~~~~~~~~ /usr/include/c++/13/bits/hashtable.h:530:7: error: use of deleted function ‘std::__detail::_Hashtable_base<_Key, _Value, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _Traits>::_Hashtable_base() [with _Key = num; _Value = std::pair<const num, int>; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<num>; _Hash = std::hash<num>; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _Traits = std::__detail::_Hashtable_traits<true, false, true>]’ In file included from /usr/include/c++/13/bits/hashtable.h:35: /usr/include/c++/13/bits/hashtable_policy.h:1710:7: note: ‘std::__detail::_Hashtable_base<_Key, _Value, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _Traits>::_Hashtable_base() [with _Key = num; _Value = std::pair<const num, int>; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<num>; _Hash = std::hash<num>; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _Traits = std::__detail::_Hashtable_traits<true, false, true>]’ is implicitly deleted because the default definition would be ill-formed: 1710 | _Hashtable_base() = default; | ^~~~~~~~~~~~~~~ /usr/include/c++/13/bits/hashtable_policy.h:1710:7: error: use of deleted function ‘std::__detail::_Hash_code_base<_Key, _Value, _ExtractKey, _Hash, _RangeHash, _Unused, __cache_hash_code>::_Hash_code_base() [with _Key = num; _Value = std::pair<const num, int>; _ExtractKey = std::__detail::_Select1st; _Hash = std::hash<num>; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; bool __cache_hash_code = true]’ /usr/include/c++/13/bits/hashtable_policy.h: In instantiation of ‘std::__detail::_Hashtable_ebo_helper<_Nm, _Tp, true>::_Hashtable_ebo_helper() [with int _Nm = 1; _Tp = std::hash<num>]’: /usr/include/c++/13/bits/hashtable_policy.h:1297:7: required from here /usr/include/c++/13/bits/hashtable_policy.h:1214:49: error: use of deleted function ‘std::hash<num>::hash()’ 1214 | _Hashtable_ebo_helper() noexcept(noexcept(_Tp())) : _Tp() { } | ^~~~~ In file included from /usr/include/c++/13/bits/basic_string.h:4379, from /usr/include/c++/13/string:54, from /usr/include/c++/13/bits/locale_classes.h:40, from /usr/include/c++/13/bits/ios_base.h:41, from /usr/include/c++/13/ios:44, from /usr/include/c++/13/ostream:40, from /usr/include/c++/13/iostream:41, from answer.code:1: /usr/include/c++/13/bits/functional_hash.h:102:12: note: ‘std::hash<num>::hash()’ is implicitly deleted because the default definition would be ill-formed:...