This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
#define int int64_t
#define pb push_back
#define pii pair<int, int>
#define st first
#define nd second
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
pii tab[10];
int dir[10];
int dis[10];
bool vis[10];
int n;
int ans = 0;
int check(int x, int y) {
int d1 = abs(tab[x].st-tab[y].st);
int d2 = abs(tab[x].nd-tab[y].nd);
if(d1!=d2) return -1;
pii p1 = {tab[x].st+dx[dir[x]]*d1, tab[x].nd+dy[dir[x]]*d1};
pii p2 = {tab[y].st+dx[dir[y]]*d1, tab[y].nd+dy[dir[y]]*d1};
if(p1!=p2) return -1;
return d1;
}
void dijkstra() {
// for(int i=0;i<n;i++) cerr << dir[i] << " ";
// cerr << "\n";
vector<int> v(n-1);
iota(all(v), 1);
do {
int cnt = 1;
vector<int> d(n-1, 1e9);
for(int i=0;i<n-1;i++) {
int x = check(v[i], 0);
if(x!=-1) {
d[i] = min(d[i], x);
}
for(int j=i-1;j>=0;j--) {
int y = check(v[i], v[j]);
if(y<d[j]) continue;
d[i] = min(d[i], y);
}
if(d[i]<1e9) cnt++;
else break;
}
ans = max(ans, cnt);
} while(next_permutation(all(v)));
}
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> n;
for(int i=0;i<n;i++) {
cin >> tab[i].st >> tab[i].nd;
}
for(int i=0;i<(1<<(2*n));i++) {
for(int j=0;j<2*n;j+=2) {
bool a = i&(1<<j);
bool b = i&(1<<(j+1));
dir[j/2] = 2*a+b;
}
dijkstra();
}
cout << ans << "\n";
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |