Submission #684597

#TimeUsernameProblemLanguageResultExecution timeMemory
684597GusterGoose27Paralelogrami (COCI17_paralelogrami)C++11
28 / 140
1 ms468 KiB
#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 good(int x, int y, int z) { pii a = 2*points[z]-points[x]-points[y]; return (a.first > 0 && a.second > 0) || (a.first < 0 && a.second < 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 = 0, b = 1, c = -1; for (int i = 2; i < n; i++) { if ((points[i]-points[a])*(points[i]-points[b]) != 0) { c = i; break; } } if (c == -1) { cout << "-1\n"; return 0; } if (good(c, b, a)) { swap(a, c); } else if (good(c, a, b)) { swap(b, c); } assert(good(a, b, c)); // c is good if ((2*points[c]-points[a]-points[b]).first < 0) make_action(a, b, c); for (int i = 0; i < 100; 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 (stderr)

paralelogrami.cpp: In function 'int main()':
paralelogrami.cpp:85:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<action>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   85 |  for (int i = 0; i < actions.size(); i++) {
      |                  ~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...