标签:struct strong end vector using col span cto ash
错误AC解法,sort+set判重,为考虑异构!
比较坑的一点是读入时scanf一定要一次读6个数,不然会TLE
#include <set> #include <map> #include <cmath> #include <queue> #include <vector> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <algorithm> using namespace std; struct node{ int a,b,c,d,e,f,hash; node(int a,int b,int c,int d,int e,int f):a(a),b(b),c(c),d(d),e(e),f(f){} bool operator<(const node&x)const{ if(a==x.a&&b==x.b&&c==x.c&&d==x.d&&e==x.e)return f<x.f; if(a==x.a&&b==x.b&&c==x.c&&d==x.d)return e<x.e; if(a==x.a&&b==x.b&&c==x.c)return d<x.d; if(a==x.a&&b==x.b)return c<x.c; if(a==x.a)return b<x.b; return a<x.a; } }; set<node>s; int n,l[6]; int main(){ scanf("%d",&n); for(int i=1;i<=n;i++){ scanf("%d%d%d%d%d%d",&l[0],&l[1],&l[2],&l[3],&l[4],&l[5]),sort(l,l+6); node snow=node(l[0],l[1],l[2],l[3],l[4],l[5]); if(s.find(snow)!=s.end()){puts("Twin snowflakes found.");return 0;} s.insert(snow); } puts("No two snowflakes are alike."); return 0; }
C++-POJ3349-Snowflake Snow Snowflakes[STL][set][hash未写]
标签:struct strong end vector using col span cto ash
原文地址:https://www.cnblogs.com/JasonCow/p/12304569.html