제출 #846296

#제출 시각아이디문제언어결과실행 시간메모리
846296vjudge1SIR (COI15_sir)C++17
12 / 100
1044 ms11856 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; using namespace std; #define PB push_back #define POB pop_back #define ordered_set \ tree<int, null_type, less<int>, rb_tree_tag, \ tree_order_statistics_node_update> #define int int64_t #define F first #define S second #define I insert #define sqr(a) ((a) * (a)) #define P pop #define max3(a, b, c) (max(a, max(b, c))) #define max4(a, b, c, d) (max(max(a, b), max(c, d))) #define min3(a, b, c) (min(a, min(b, c))) #define min4(a, b, c, d) (min(min(a, b), min(c, d))) #define MOD 1000000007 #define mod 998244353 int binpow(int a, int p, int m = MOD) { int ans = 1; while (p) { if (p & 1) ans = ((ans % m) * (a % m)) % m; a = sqr(a) % m; p >>= 1; } return ans; } vector<pair<int, int>> p, v; int totar = 0; int area2(int A, int B, int C) { auto a = v[A], b = v[B], c = v[C]; double ab = sqrt(sqr(a.F - b.F) + sqr(a.S - b.S)), ac = sqrt(sqr(a.F - c.F) + sqr(a.S - c.S)), bc = sqrt(sqr(c.F - b.F) + sqr(c.S - b.S)); double u = (ab + ac + bc) / double(2); return ceil((double(2) * sqrt(u * (u - ac) * (u - ab) * (u - bc))) - 0.5); } int calc(int L, int R, int area) { auto l = v[L], r = v[R]; r.F -= l.F; r.S -= l.S; swap(r.F, r.S); r.S *= -1; bool b; for (int i = 0; i < p.size(); i++) { int ans = (p[i].F - l.F) * r.F + (p[i].S - l.S) * r.S; if (ans == 0) return 0; if (i == 0 && ans < 0) b = false; else if (i == 0) b = true; else if (b && ans < 0) return 0; else if ((!b) && ans > 0) return 0; } if (b) return totar - area; else return area; } void solve() { int n, m; cin >> n; v.assign(n, {0, 0}); for (int i = 0; i < n; i++) cin >> v[i].F >> v[i].S; for (int i = 2; i < n; i++) { totar += area2(0, i - 1, i); } cin >> m; p.assign(m, {0, 0}); for (int i = 0; i < m; i++) cin >> p[i].F >> p[i].S; int maxi = 0; for (int i = 0; i < n; i++) { int curr = 0; for (int j = (i + 2) % n; j != ((i - 1 + n) % n); j = (j + 1) % n) { curr += area2(i, (j - 1 + n) % n, j); if (abs(j - i) <= 1) continue; int ansi = calc(i, j, curr); maxi = max(maxi, ansi); } } cout << maxi << endl; } int32_t main() { int t = 1; // cin >> t; while (t--) { solve(); } }

컴파일 시 표준 에러 (stderr) 메시지

sir.cpp: In function 'int64_t calc(int64_t, int64_t, int64_t)':
sir.cpp:50:23: warning: comparison of integer expressions of different signedness: 'int64_t' {aka 'long int'} and 'std::vector<std::pair<long int, long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |     for (int i = 0; i < p.size(); i++) {
      |                     ~~^~~~~~~~~~
sir.cpp:62:5: warning: 'b' may be used uninitialized in this function [-Wmaybe-uninitialized]
   62 |     if (b)
      |     ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...