Submission #684602

# Submission time Handle Problem Language Result Execution time Memory
684602 2023-01-22T00:45:36 Z GusterGoose27 Paralelogrami (COCI17_paralelogrami) C++11
0 / 140
0 ms 212 KB
#include <bits/stdc++.h>

using namespace std;

typedef pair<int, int> pii;

const int MAXN = 400;
pii points[MAXN];
int n;

pii operator+(pii a, pii b) {
	return pii(a.first+b.first, a.second+b.second);
}

pii operator-(pii a, pii b) {
	return pii(a.first-b.first, a.second-b.second);
}

int operator*(pii a, pii b) {
	return a.first*b.second-a.second*b.first;
}

pii operator*(int a, pii b) {
	return pii(a*b.first, a*b.second);
}

class action {
public:
	int a, b, c;
	action(int a, int b, int c) : a(a), b(b), c(c) {}
};

vector<action> actions;

void make_action(int a, int b, int c) {
	actions.push_back(action(a, b, c));
	points[c] = points[a]+points[b]-points[c];
}

void reflect(int a, int b, int c) { // reflect triangle about c
	make_action(c, b, a);
	make_action(c, a, b);
	make_action(c, b, a);
}

bool x_good = 0, y_good = 0;

bool good(int x, int y, int z) {
	pii a = 2*points[z]-points[x]-points[y];
	if (a.first > 0 && a.second > 0) {
		return 1;
	}
	if (a.first < 0 && a.second < 0) {
		make_action(x, y, z);
		return 1;
	}
	return 0;
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> points[i].first >> points[i].second;
	}
	int a, b, c = -1;
	for (int i = 0; i < n-2 && c != -1; i++) {
		for (int j = i+1; j < n-1 && c != -1; j++) {
			for (int k = j+1; k < n && c != -1; k++) {
				if (good(i, j, k)) {
					a = i;
					b = j;
					c = k;
					continue;
				}
				if (good(i, k, j)) {
					a = i;
					b = k;
					c = j;
					continue;
				}
				if (good(j, k, i)) {
					a = j;
					b = k;
					c = i;
				}
			}
		}
	}
	if (c == -1) {
		cout << "-1\n";
		return 0;
	}
	for (int i = 0; i < 30; i++) {
		reflect(a, b, c);
		make_action(a, b, c);
	}
	for (int i = 0; i < n; i++) {
		if (i == a || i == b || i == c) continue;
		make_action(a, b, i);
	}
	cout << actions.size() << "\n";
	for (int i = 0; i < actions.size(); i++) {
		action m = actions[i];
		cout << (1+m.a) << " " << (1+m.b) << " " << (1+m.c) << "\n";
	}
}

Compilation message

paralelogrami.cpp: In function 'int main()':
paralelogrami.cpp:103:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<action>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  103 |  for (int i = 0; i < actions.size(); i++) {
      |                  ~~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -