-
Notifications
You must be signed in to change notification settings - Fork 1
/
1595 - Symmetry.cpp
123 lines (119 loc) · 2.95 KB
/
1595 - Symmetry.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/*
Author :: MD. Musfiqur Rahman Sanim
Aust cse 28th Batch
ID:11.02.04.097
*/
//{ Template
using namespace std;
//{ C-headers
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <cfloat>
#include <cctype>
#include <cassert>
#include <ctime>
//}
//{ C++-headers
#include <iostream>
#include <iomanip>
#include <sstream>
#include <algorithm>
#include <utility>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
//}
//{ Loops
#define forab(i,a,b) for (__typeof(b) i = (a); i <= (b); ++i)
#define rep(i,n) forab (i, 0, (n) - 1)
#define For(i,n) forab (i, 1, n)
#define rofba(i,a,b) for (__typeof(b) i = (b); i >= (a); --i)
#define per(i,n) rofba (i, 0, (n) - 1)
#define rof(i,n) rofba (i, 1, n)
#define forstl(i,s) for (__typeof ((s).end ()) i = (s).begin (); i != (s).end (); ++i)
//}
//{ Floating-points
#define EPS 1e-7
#define abs(x) (((x) < 0) ? - (x) : (x))
#define zero(x) (abs (x) < EPS)
#define equal(a,b) (zero ((a) - (b)))
#define PI 2*acos (0.0)
//}
typedef long long int64;
typedef unsigned long long int64u;
#define memo(a,v) memset(a,v,sizeof(a))
#define all(a) a.begin(),a.end()
#define db double
#define pb push_back
#define pii pair<int ,int >
#define NL puts("")
//{
//Intput_Output
#define II ({ int a; scanf("%d",&a); a;})
#define IL ({ int64 a; scanf("%lld",&a); a;})
#define ID ({ db a; scanf("%lf",&a); a;})
#define IC ({ char a; scanf("%c",&a); a;})
#define IS ({ string a; cin >> a; a;})
#define ICA(n) ({ char a[n]; scanf("%s",&a); a;})
#define OC printf("Case %d:",cs);
//}
//}
template <class T, class U> inline T max (T &a, U &b)
{
return a > b ? a : b;
}
template <class T, class U> inline T min (T &a, U &b)
{
return a < b ? a : b;
}
template <class T, class U> inline T swap (T &a, U &b)
{
T tmp = a;
a = b;
b = tmp;
}
//int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
//int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//int dx[6]={2,1,-1,-2,-1,1};int dy[6]={0,1,1,0,-1,-1}; //Hexagonal Direction
const int64 INF = (500000LL * 1000000000LL) + 7LL;
const int mx = 10000*2 + 7;
const db pi = PI;
int EQ(double d){
if ( fabs(d) < EPS ) return 0;
return d > EPS ? 1 : -1 ;
}
vector<int >V[mx];
set<pii >S;
int main(){
#ifdef Sanim
freopen ("in.txt", "r", stdin);
// freopen ("output.txt", "w", stdout);
#endif
int t = II;
For(cs,t){
int n = II;
rep(i,n){
int x = II,y = II + 10000;
V[y].pb(x);
}
rep(i,mx){
if(V[i].size() == 0) continue;
int ret = 0;
forstl(it,V[i]) ret += *it;
int s = V[i].size();
int tmp = __gcd(ret,s);
S.insert(pii(ret/tmp,s/tmp));
V[i].clear();
}
if(S.size() == 1) cout << "YES" << endl;
else cout << "NO" << endl;
S.clear();
}
}