萌新求助

P1001 A+B Problem

Zhangikun @ 2023-04-16 10:59:42

当然我这题已经AC了,但是我有个问题:

#include<bits/stdc++.h>
using namespace std;
template<class T1,class T2>struct ikundered_map
{
  vector<pair<T1,T2> >hash[114514];//T1为下标的类型,T2为存储的类型
  int put_id(T1 x)
  {
    int id;
    if(typeid(T1)==typeid(1)||typeid(T1)==typeid(10000000000LL)||typeid(T1)==typeid('A')||typeid(T1)==typeid(false)||typeid(T1)==typeid(float(0.1))||typeid(T1)==typeid(0.1))
    id=((int)x%114514+114514)%114514;
    else
    id=put_id(x[0]);
    return id;
  }
  T2& operator[](T1 x)
  {
    int id;
    id=put_id(x);
    for(int i=0;i<hash[id].size();i++)
    {
      if(hash[id][i].first==x)
      {
        return hash[id][i].second;
      }
    }
    T2 num;
    hash[id].push_back({x,num});
    return hash[id][hash[id].size()-1].second;
  }
};
int main()
{
  string s;
  vector<string>v;
  int n;
  cin>>n;
  ikundered_map<string,bool>kun;
  for(int i=1;i<=n;i++)
  {
    cin>>s;
    if(kun[s]==0)
    {
      v.push_back(s);
      kun[s]=1;
    }
  }
  for(int i=0;i<v.size();i++)
  {
    cout<<v[i]<<" ";
  }
  return 0;
}

这个手写哈希为什么不能通过编译


by __HHX__ @ 2023-04-21 21:07:43

看题解去吧你


by audvnj @ 2023-04-24 20:30:57

有没有一种可能这题不需要那么麻烦?


by CznTree @ 2023-05-05 19:14:16

@hycJuRuo 用 stoi


by COKENOTFOUND @ 2023-05-14 12:07:01

下标好臭


by zhang8031 @ 2023-05-20 17:58:36

直接A+B不就好了吗? cout << A+B; ???


by zhang8031 @ 2023-05-20 17:59:25

@audvnj 对对对


上一页 |