TC SRM 521 (div. 2) 1000'
比赛时候没搞出来,在赛后好像只能提交不能评测不知道为什么,故我也不知道自己搞得对不对。不过这道题让我会用了map(看了同一房间里面的一个大牛的代码后,而且这个大牛是个中学生好像……)。
#include <algorithm> #include <bitset> #include <cctype> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <utility> #include <vector> using namespace std; const double pi = acos(-1.0); const double eps = 1e-11; class SquaredSubsets { public: long long countSubsets(int n, vector <int> x, vector <int> y) { int s = x.size(), h = 0, v = 0; long x0[551], y0[551]; map <long long, bool> mymap; long long sum = 0; n <<= 1; for(int i = 0; i < s; i++) { x[i] <<= 1; y[i] <<= 1; x0[++h] = x[i]; x0[++h] = x[i] - 1; x0[++h] = x[i] + n + 1; y0[++v] = y[i]; y0[++v] = y[i] - 1; y0[++v] = y[i] + n + 1; } mymap[0] = 1; for(int i = 1; i <= h; i++) for(int j = 1; j <= h; j++) { long long SC = 0; for(int k = 0; k < s; k++) if(x[k] >= x0[i] - n && x[k] <= x0[i] && y[k] >= y0[j] - n && y[k] <= y0[j]) SC |= 1 << k; if(!mymap.count(SC)) { sum++; mymap[SC] = 1; } } return sum; } };