Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

stl水过~

Posted by 416221843 at 2017-07-29 13:12:30 on Problem 3349
直接暴力找12次是超时的..所有相同的雪花都对应同一个排序后的数组 读数据后先排序 再查找插入 就好
似乎要重载运算符才能结构体查找
#include<cstdio>
#include<cstring>
#include<queue>
#include <algorithm>
#include<set>
using namespace std;
struct vii { int a, b, c, d, e, f;
vii(int _a = 0, int _b = 0, int _c = 0, int _d = 0, int _e = 0, int _f = 0)
	:a(_a), b(_b), c(_c), d(_d), e(_e), f(_f) {}
bool operator <(const vii &r)const
{
	if (a == r.a&&b == r.b&&c == r.c&&d == r.d&&e == r.e) return f < r.f;
	if (a == r.a&&b == r.b&&c == r.c&&d == r.d) return e < r.e;
	if (a == r.a&&b == r.b&&c == r.c) return d < r.d;
	if (a == r.a&&b == r.b) return c < r.c;
	if (a == r.a) return b < r.b;
	return a < r.a;
}
};
set<vii>viia;
int main()
{
	int n, i, mp[6];
	scanf("%d", &n);
	for (i = 0; i < n; i++)
	{
		scanf("%d%d%d%d%d%d", mp, mp + 1, mp + 2, mp + 3, mp + 4, mp + 5);
		sort(mp, mp + 6);
		if (viia.find(vii(mp[0], mp[1], mp[2], mp[3], mp[4], mp[5])) != viia.end())
			break;
		viia.insert(vii(mp[0], mp[1], mp[2], mp[3], mp[4], mp[5]));
	}
	puts(i == n ? "No two snowflakes are alike." : "Twin snowflakes found.");
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator