답안 #837531

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
837531 2023-08-25T11:53:01 Z EntityPlantt Planine (COCI21_planine) C++14
20 / 110
236 ms 8084 KB
#include <cstdio>
#include <algorithm>
using namespace std;
int n, h, i, c;
#define st second
#define en first
pair <double, double> inte[500005];
double x1, y1, x2, y2, x3, y3, l = -1e18;
int main() {
    scanf("%d%d%lf%lf%lf%lf", &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("%lf%lf%lf%lf", &x2, &y2, &x3, &y3);
        inte[i].st = x1 + (h - y1) * (x1 - x2) / (y1 - y2);
        inte[i].en = x2 + (h - y2) * (x2 - x3) / (y2 - y3);
    }
    sort(inte, inte + n);
    for (i = 0; i < n; i++) {
        if (l + 1e-10 < inte[i].st) {
            l = inte[i].en;
            c++;
        }
    }
    printf("%d", c);
    return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:10:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |     scanf("%d%d%lf%lf%lf%lf", &n, &h, &x3, &y3, &x3, &y3);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:18:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |         scanf("%lf%lf%lf%lf", &x2, &y2, &x3, &y3);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 340 KB Output is correct
2 Correct 2 ms 340 KB Output is correct
3 Correct 2 ms 340 KB Output is correct
4 Correct 21 ms 1068 KB Output is correct
5 Correct 21 ms 1048 KB Output is correct
6 Correct 26 ms 1000 KB Output is correct
7 Correct 211 ms 8084 KB Output is correct
8 Correct 236 ms 8064 KB Output is correct
9 Correct 224 ms 8004 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 340 KB Output is correct
2 Correct 2 ms 340 KB Output is correct
3 Correct 2 ms 340 KB Output is correct
4 Correct 21 ms 1068 KB Output is correct
5 Correct 21 ms 1048 KB Output is correct
6 Correct 26 ms 1000 KB Output is correct
7 Correct 211 ms 8084 KB Output is correct
8 Correct 236 ms 8064 KB Output is correct
9 Correct 224 ms 8004 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Incorrect 1 ms 212 KB Output isn't correct
12 Halted 0 ms 0 KB -