Finished c and d, e doesn't check for faulty arrangements
This commit is contained in:
@@ -2,23 +2,57 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
void test_case(int tc){
|
||||
typedef long long ll;
|
||||
|
||||
set<pair<ll, ll>> spells;
|
||||
|
||||
ll gcd(ll a, ll b){
|
||||
if(b == 0){
|
||||
return a;
|
||||
}
|
||||
|
||||
return gcd(b, a % b);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main(){
|
||||
ios::sync_with_stdio(0);
|
||||
cin.tie(0);
|
||||
|
||||
int t;
|
||||
cin >> t;
|
||||
int n;
|
||||
cin >> n;
|
||||
|
||||
for(int tc = 1; tc <= t; ++tc){
|
||||
test_case(tc);
|
||||
vector<pair<ll, ll>> cities(n);
|
||||
|
||||
for(int i = 0; i < n; ++i){
|
||||
ll x, y;
|
||||
|
||||
cin >> x >> y;
|
||||
cities[i] = {x, y};
|
||||
|
||||
for(int j = 0; j < i; ++j){
|
||||
ll dx = cities[j].first - cities[i].first;
|
||||
ll dy = cities[j].second - cities[i].second;
|
||||
|
||||
if(dx == 0){
|
||||
spells.insert({0, 1});
|
||||
spells.insert({0,-1});
|
||||
} else if(dy == 0){
|
||||
spells.insert({1,0});
|
||||
spells.insert({-1, 0});
|
||||
} else{
|
||||
ll g = gcd(dx, dy);
|
||||
|
||||
dx /= g;
|
||||
dy /= g;
|
||||
|
||||
spells.insert({dx, dy});
|
||||
spells.insert({-1*dx, -1*dy});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cout << spells.size();
|
||||
|
||||
cout << flush;
|
||||
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user