Submission #837599

#TimeUsernameProblemLanguageResultExecution timeMemory
837599EntityPlanttPlanine (COCI21_planine)C++17
0 / 110
2 ms340 KiB
#include <cstdio> #include <algorithm> using namespace std; typedef long long ll; struct frac { ll x, y; bool operator<(const frac &f) const { if (y * f.y < 0) return x * f.y > y * f.x; return x * f.y < y * f.x; } } l; int n, h, i, c = 1, x1, y1, x2, y2, x3, y3; pair <frac, frac> inte[500005]; int main() { scanf("%d%d%d%d%d%d", &n, &h, &x3, &y3, &x3, &y3); if (n == 3) { printf("0"); return 0; } n = n / 2 - 1; for (i = 0; i < n; i++) { x1 = x3; y1 = y3; scanf("%d%d%d%d", &x2, &y2, &x3, &y3); inte[i].first = {x1 * (y1 - y2) + (h - y1) * (x1 - x2), y1 - y2}; inte[i].second = {x2 * (y2 - y3) + (h - y2) * (x2 - x3), y2 - y3}; } sort(inte, inte + n); l = inte[0].second; for (i = 1; i < n; i++) { if (l < inte[i].first) { l = inte[i].second; c++; } } printf("%d", c); return 0; }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:15:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |     scanf("%d%d%d%d%d%d", &n, &h, &x3, &y3, &x3, &y3);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:23:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |         scanf("%d%d%d%d", &x2, &y2, &x3, &y3);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...