想用hash来判重,但以前从没有过它,想了半天,想不出来,最后直接暴力判重,希望有大佬告诉我怎么判
#include<bits/stdc++.h>
#define INF 0x3f3f3f3f
#define ll long long
#define mem(ar,num) memset(ar,num,sizeof(ar))
#define me(ar) memset(ar,0,sizeof(ar))
#define lowbit(x) (x&(-x))
#define IOS ios::sync_with_stdio(false)
#define DEBUG cout<<endl<<"DEBUG"<<endl;
using namespace std;
string in;
map<int, map<int,map<int,int>>>mp;
int arr[100010], a, m, ans;
int hashs(int a, int b, int c) {if(mp[a][b][c] != 1) {mp[a][b][c] = 1;mp[a][c][b] = 1;mp[c][b][a] = 1;mp[c][a][b] = 1;mp[b][a][c] = 1;mp[b][c][a] = 1;return 1;} elsereturn 0;
}
int main() {while(cin >> in) {ans = 0;while(in.find(',') != -1) {arr[a++] = atoi(in.substr(0, in.find(',')).c_str());in.erase(0, in.find(',') + 1);}arr[a++] = atoi(in.c_str());sort(arr, arr + a);for(int i = 0; i < a; i++) {for(int j = i + 1; j < a ; j++) {for(int k = j + 1; k < a; k++) {if(arr[i] + arr[j] + arr[k] == 0 && hashs(arr[i], arr[j], arr[k])) {ans++;}}}}cout << ans;me(arr);a = 0;}return 0;
}