A. prefix hash+ Inverse element
#include <iostream>#include<cstdlib>#include<cstdio>#include<cstring>#include<cmath>#include<stack>#include<string>#include<vector>#include<map>#include<algorithm>Const intINF =0x3f3f3f;Const intMAXN = 1e7+Ten;using namespacestd;intMain () {intN; Charts[ +]; Map<string,int>Hash; Map<string,int>:: Iterator Li; while(SCANF ("%d", &n)! =EOF) {hash.clear (); for(intI=0; i<n;i++) {scanf ("%s", TS); intLen =strlen (TS); Sort (Ts,ts+Len); stringTMP = (string) TS; Li=Hash.find (TMP); if(li==Hash.end ()) {cout<<0<<Endl; HASH[TMP]++; }Else{cout<Endl; HASH[TMP]++; } } } //cout << "Hello world!" << Endl; return 0;}
View Code
D.sort+map
#include <iostream>#include<cstdlib>#include<cstdio>#include<cstring>#include<cmath>#include<stack>#include<string>#include<vector>#include<map>#include<algorithm>Const intINF =0x3f3f3f;Const intMAXN = 1e7+Ten;using namespacestd;intMain () {intN; Charts[ +]; Map<string,int>Hash; Map<string,int>:: Iterator Li; while(SCANF ("%d", &n)! =EOF) {hash.clear (); for(intI=0; i<n;i++) {scanf ("%s", TS); intLen =strlen (TS); Sort (Ts,ts+Len); stringTMP = (string) TS; Li=Hash.find (TMP); if(li==Hash.end ()) {cout<<0<<Endl; HASH[TMP]++; }Else{cout<Endl; HASH[TMP]++; } } } //cout << "Hello world!" << Endl; return 0;}
View Code
201,600-degree Star Qualifying tournament