結果
問題 | No.2769 Number of Rhombi |
ユーザー | ぷら |
提出日時 | 2024-05-31 22:34:27 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 1,266 ms / 5,000 ms |
コード長 | 4,344 bytes |
コンパイル時間 | 1,563 ms |
コンパイル使用メモリ | 147,368 KB |
実行使用メモリ | 65,920 KB |
最終ジャッジ日時 | 2024-05-31 22:35:05 |
合計ジャッジ時間 | 34,445 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,816 KB |
testcase_01 | AC | 2 ms
6,940 KB |
testcase_02 | AC | 2 ms
6,940 KB |
testcase_03 | AC | 643 ms
46,208 KB |
testcase_04 | AC | 570 ms
40,704 KB |
testcase_05 | AC | 519 ms
28,544 KB |
testcase_06 | AC | 702 ms
35,456 KB |
testcase_07 | AC | 1,048 ms
43,136 KB |
testcase_08 | AC | 1,085 ms
45,184 KB |
testcase_09 | AC | 1,110 ms
49,152 KB |
testcase_10 | AC | 1,226 ms
54,528 KB |
testcase_11 | AC | 1,199 ms
58,624 KB |
testcase_12 | AC | 1,266 ms
61,952 KB |
testcase_13 | AC | 1,170 ms
64,000 KB |
testcase_14 | AC | 1,153 ms
65,280 KB |
testcase_15 | AC | 1,086 ms
65,664 KB |
testcase_16 | AC | 1,067 ms
65,792 KB |
testcase_17 | AC | 1,050 ms
65,792 KB |
testcase_18 | AC | 1,044 ms
65,920 KB |
testcase_19 | AC | 984 ms
65,792 KB |
testcase_20 | AC | 1,008 ms
65,920 KB |
testcase_21 | AC | 1,001 ms
65,792 KB |
testcase_22 | AC | 952 ms
65,920 KB |
testcase_23 | AC | 950 ms
65,792 KB |
testcase_24 | AC | 2 ms
6,940 KB |
testcase_25 | AC | 1,125 ms
63,744 KB |
testcase_26 | AC | 1,126 ms
64,768 KB |
testcase_27 | AC | 1,022 ms
65,792 KB |
testcase_28 | AC | 1,086 ms
65,536 KB |
testcase_29 | AC | 1,022 ms
65,792 KB |
testcase_30 | AC | 1,068 ms
65,664 KB |
testcase_31 | AC | 1,173 ms
61,824 KB |
testcase_32 | AC | 1,073 ms
45,440 KB |
testcase_33 | AC | 1,087 ms
45,440 KB |
testcase_34 | AC | 1,158 ms
52,736 KB |
ソースコード
#include <string.h> #include <algorithm> #include <array> #include <bitset> #include <cassert> #include <cfloat> #include <climits> #include <cmath> #include <complex> #include <ctime> #include <deque> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <iterator> #include <list> #include <map> #include <memory> #include <queue> #include <random> #include <set> #include <stack> #include <string> #include <unordered_map> #include <unordered_set> #include <utility> #include <vector> using namespace std; using ll = long long; using pii = pair<int,int>; using pll = pair<ll,ll>; template <typename T> using vc = vector<T>; template <typename T> using vvc = vector<vector<T>>; template <typename T> using vvvc = vector<vector<vector<T>>>; template<class T> using pq = priority_queue<T,vector<T>,greater<T>>; template <class T, class S> inline bool chmax(T &a, const S &b) { return (a < b ? a = b, 1 : 0); } template <class T, class S> inline bool chmin(T &a, const S &b) { return (a > b ? a = b, 1 : 0); } int dx4[] = {1,0,-1,0}; int dy4[] = {0,1,0,-1}; #define overload5(a, b, c, d, e, name, ...) name #define overload4(a, b, c, d, name, ...) name #define REP0(n) for(ll jidlsjf = 0; jidlsjf < n; ++jidlsjf) #define REP1(i, n) for(ll i = 0; i < (n); ++i) #define REP2(i, a, b) for(ll i = (a); i < (b); ++i) #define REP3(i, a, b, c) for(ll i = (a); i < (b); i += (c)) #define rep(...) overload4(__VA_ARGS__, REP3, REP2, REP1, REP0)(__VA_ARGS__) #define per0(n) for(int jidlsjf = 0; jidlsjf < (n); ++jidlsjf) #define per1(i, n) for(ll i = (n)-1; i >= 0; --i) #define per2(i, a, b) for(ll i = (a)-1; i >= b; --i) #define per3(i, a, b, c) for(ll i = (a)-1; i >= (b); i -= (c)) #define per(...) overload4(__VA_ARGS__, per3, per2, per1, per0)(__VA_ARGS__) #define setbits(j, n) for(ll iiiii = (n), j = lowbit(iiiii); iiiii; iiiii ^= 1 << j, j = lowbit(iiiii)) #define perm(v) for(bool permrepflag = true; (permrepflag ? exchange(permrepflag, false) : next_permutation(all(v)));) #define fi first #define se second #define pb push_back #define ppb pop_back #define ppf pop_front #define drop(s) cout << #s << endl, exit(0) #define si(c) (int)(c).size() #define lb(c, x) distance((c).begin(), lower_bound(all(c), (x))) #define lbg(c, x) distance((c).begin(), lower_bound(all(c), (x), greater{})) #define ub(c, x) distance((c).begin(), upper_bound(all(c), (x))) #define ubg(c, x) distance((c).begin(), upper_bound(all(c), (x), greater{})) #define rng(v, l, r) v.begin() + (l), v.begin() + (r) #define all(c) c.begin(), c.end() #define rall(c) c.rbegin(), c.rend() #define SORT(v) sort(all(v)) #define REV(v) reverse(all(v)) #define UNIQUE(x) SORT(x), x.erase(unique(all(x)), x.end()) #define MIN(v) *min_element(all(v)) #define MAX(v) *max_element(all(v)) #define overload2(_1, _2, name, ...) name #define vec(type, name, ...) vector<type> name(__VA_ARGS__) #define vv(type, name, h, ...) vector<vector<type>> name(h, vector<type>(__VA_ARGS__)) #define vvv(type, name, h, w, ...) vector<vector<vector<type>>> name(h, vector<vector<type>>(w, vector<type>(__VA_ARGS__))) long long binary_gcd(long long a,long long b) { if(a == 0 || b == 0) return a+b; int k = 0; while(!((a&1)|(b&1))) { k++; a >>= 1; b >>= 1; } while (a != b) { while(!(a&1)) a >>= 1; while(!(b&1)) b >>= 1; if(a > b) a -= b; else if(a < b) b -= a; } return a << k; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; vc<int>x(n),y(n); rep(i,n) { cin >> x[i] >> y[i]; } map<array<int,4>,int>mp; ll ans = 0; rep(i,n) { rep(j,i+1,n) { int mx = x[i]+x[j]; int my = y[i]+y[j]; int gx = x[i]-x[j]; int gy = y[i]-y[j]; int g = binary_gcd(abs(gx),abs(gy)); gx /= g; gy /= g; if(gx < 0) { gx = -gx; gy = -gy; } if(gx == 0) gy = 1; if(gy == 0) gx = 1; mp[{mx,my,gx,gy}]++; if(gy < 0) { gx = -gx; gy = -gy; } if(gx == 0) gy = 1; if(gy == 0) gx = -1; ans += mp[{mx,my,gy,-gx}]; } } cout << ans << "\n"; }