code festival 2014 上海

Submission #596694

Source codeソースコード

#include <cstdio>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <map>
#include <iostream>
#include <algorithm>

using namespace std;

const int N = 100000 + 10;
const int MOD = (int)1e9 + 7;

int n;
int x[N], y[N];
map<pair<int, int>, int> vec;

void solve()
{
	cin >> n;
	for(int i = 0; i < n; ++ i) {
		cin >> x[i] >> y[i];
		vec[make_pair(x[i], y[i])] = i;
	}
	for(int i = 0; i < n; ++ i) {
		for(int j = i + 1; j < n; ++ j) {
			int vy = x[i] - x[j];
			int vx = y[j] - y[i];
			for(int k = 0; k < 2; ++ k) {
				if (vec.count(make_pair(x[i] + vx, y[i] + vy)) && vec.count(make_pair(x[j] + vx, y[j] + vy))) {
					cout << 4 << endl;
					vector<int> ids;
					ids.push_back(i + 1);
					ids.push_back(j + 1);
					ids.push_back(vec[make_pair(x[i] + vx, y[i] + vy)] + 1);
					ids.push_back(vec[make_pair(x[j] + vx, y[j] + vy)] + 1);
					sort(ids.begin(), ids.end());
					for(int w = 0; w < 4; ++ w) {
						cout << ids[w] << endl;
					}
					return;
				}
				vx = -vx;
				vy = -vy;
			}
		}
	}
	cout << 0 << endl;
}

int main()
{
	solve();
	return 0;
}

Submission

Task問題 C - Regular Polygon
User nameユーザ名 AngryBacon
Created time投稿日時
Language言語 C++ (G++ 4.6.4)
Status状態 AC
Score得点 100
Source lengthソースコード長 1153 Byte
File nameファイル名
Exec time実行時間 101 ms
Memory usageメモリ使用量 1060 KB

Test case

Set

Set name Score得点 / Max score Cases
Sample - subtask0_sample_01.txt,subtask0_sample_02.txt
All 100 / 100 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

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
subtask0_sample_01.txt AC 26 ms 940 KB
subtask0_sample_02.txt AC 25 ms 940 KB
subtask1_random01.txt AC 99 ms 1052 KB
subtask1_random02.txt AC 101 ms 1040 KB
subtask1_random03.txt AC 97 ms 1052 KB
subtask1_random04.txt AC 99 ms 1044 KB
subtask1_random05.txt AC 29 ms 1048 KB
subtask1_random06.txt AC 33 ms 1048 KB
subtask1_random07.txt AC 100 ms 1048 KB
subtask1_random08.txt AC 99 ms 1048 KB
subtask1_special01.txt AC 25 ms 1052 KB
subtask1_special02.txt AC 24 ms 1044 KB
subtask1_special03.txt AC 28 ms 1040 KB
subtask1_special04.txt AC 25 ms 1044 KB
subtask1_special05.txt AC 90 ms 1044 KB
subtask1_special06.txt AC 42 ms 1044 KB
subtask1_special07.txt AC 38 ms 1052 KB
subtask1_special08.txt AC 44 ms 1060 KB
subtask1_special09.txt AC 48 ms 1044 KB
subtask1_special10.txt AC 26 ms 1044 KB