Submission #306029


Source Code Expand

#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define each(it,n) for(__typeof((n).begin()) it=(n).begin();it!=(n).end();++it)

using namespace std;

typedef long long ll;

vector<pair<ll, ll> > points;
map<pair<ll, ll>, int> s;
int n;

void doit() {
    rep(i, n) {
        for (int j = i + 1; j < n; j++) {
            pair<ll, ll> p1 = points[i], p2 = points[j];
            pair<ll, ll> vec(p1.first - p2.first, p1.second - p2.second);
            
            pair<ll, ll> p3, p4;
            p3 = pair<ll, ll>(p1.first + vec.second, p1.second - vec.first);
            p4 = pair<ll, ll>(p2.first + vec.second, p2.second - vec.first);

            if (s.find(p3) != s.end() && s.find(p4) != s.end()) {
                cout << 4 << endl;
                vector<int> ans = {i + 1, j + 1, s[p3] + 1, s[p4] + 1};
                sort(ans.begin(), ans.end());
                rep(i, 4) {
                    cout << ans[i] << endl;
                }
                return;
            }

            p3 = pair<ll, ll>(p1.first - vec.second, p1.second + vec.first);
            p4 = pair<ll, ll>(p2.first - vec.second, p2.second + vec.first);

            if (s.find(p3) != s.end() && s.find(p4) != s.end()) {
cout << 4 << endl;
                vector<int> ans = {i + 1, j + 1, s[p3] + 1, s[p4] + 1};
                sort(ans.begin(), ans.end());
                rep(i, 4) {
                    cout << ans[i] << endl;
                }
                return;
            }
        }
    }
    cout << 0 << endl;
}

int main() {
    cin >> n;

    points = vector<pair<ll, ll> >(n);

    rep(i, n) {
        cin >> points[i].first >> points[i].second;
        s[points[i]] = i;
    }

    doit();
    
    return 0;
}

Submission Info

Submission Time
Task C - Regular Polygon
User y3eadgbe
Language C++11 (GCC 4.8.1)
Score 100
Code Size 1807 Byte
Status AC
Exec Time 104 ms
Memory 932 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 100 / 100
Status
AC × 2
AC × 20
Set Name Test Cases
Sample subtask0_sample_01.txt, subtask0_sample_02.txt
All subtask0_sample_01.txt, subtask0_sample_02.txt, subtask1_random01.txt, subtask1_random02.txt, subtask1_random03.txt, subtask1_random04.txt, subtask1_random05.txt, subtask1_random06.txt, subtask1_random07.txt, subtask1_random08.txt, subtask1_special01.txt, subtask1_special02.txt, subtask1_special03.txt, subtask1_special04.txt, subtask1_special05.txt, subtask1_special06.txt, subtask1_special07.txt, subtask1_special08.txt, subtask1_special09.txt, subtask1_special10.txt
Case Name Status Exec Time Memory
subtask0_sample_01.txt AC 25 ms 800 KB
subtask0_sample_02.txt AC 24 ms 792 KB
subtask1_random01.txt AC 103 ms 924 KB
subtask1_random02.txt AC 104 ms 912 KB
subtask1_random03.txt AC 100 ms 924 KB
subtask1_random04.txt AC 100 ms 800 KB
subtask1_random05.txt AC 31 ms 920 KB
subtask1_random06.txt AC 35 ms 796 KB
subtask1_random07.txt AC 104 ms 844 KB
subtask1_random08.txt AC 104 ms 916 KB
subtask1_special01.txt AC 26 ms 732 KB
subtask1_special02.txt AC 26 ms 804 KB
subtask1_special03.txt AC 23 ms 792 KB
subtask1_special04.txt AC 24 ms 924 KB
subtask1_special05.txt AC 92 ms 928 KB
subtask1_special06.txt AC 39 ms 928 KB
subtask1_special07.txt AC 36 ms 800 KB
subtask1_special08.txt AC 43 ms 928 KB
subtask1_special09.txt AC 52 ms 932 KB
subtask1_special10.txt AC 23 ms 800 KB