제출 #348167

#제출 시각아이디문제언어결과실행 시간메모리
348167Markomafko972Fence (CEOI08_fence)C++14
40 / 100
1 ms364 KiB
#include <bits/stdc++.h> #define X first #define Y second #define pb push_back #define pii pair<int, int> typedef long long ll; using namespace std; const int MOD = 1e9 + 7; const ll INF = 1e18; const int OFF = (1 << 20); int n, m; pii holes[105]; pii trees[105]; int dist[105][105]; vector<pii> ljuska; vector<pii> drva; int ccw(pii a, pii b, pii c) { return a.X * (b.Y - c.Y) + b.X * (c.Y - a.Y) + c.X * (a.Y - b.Y); } int main () { cin >> n >> m; for (int i = 0; i < n; i++) cin >> holes[i].X >> holes[i].Y; for (int i = 0; i < m; i++) cin >> trees[i].X >> trees[i].Y; sort(holes, holes + n); ljuska.push_back(holes[0]); ljuska.push_back(holes[1]); for (int i = 2; i < n; i++) { while (ljuska.size() > 1 && ccw(ljuska[(int)ljuska.size()-2], ljuska.back(), holes[i]) >= 0) ljuska.pop_back(); ljuska.push_back(holes[i]); } int kol = ljuska.size(); for (int i = n-2; i >= 0; i--) { while (ljuska.size() > kol && ccw(ljuska[(int)ljuska.size()-2], ljuska.back(), holes[i]) >= 0) ljuska.pop_back(); if (i > 0) ljuska.push_back(holes[i]); } for (int i = 0; i < m; i++) { int da = 1; if (ccw(ljuska.back(), ljuska[0], trees[i]) >= 0) da = 0; for (int j = 1; j < ljuska.size(); j++) { if (ccw(ljuska[j-1], ljuska[j], trees[i]) >= 0) { da = 0; break; } } if (da) drva.push_back(trees[i]); } if (drva.size() == 0) { cout << m*111; return 0; } for (int i = 0; i < ljuska.size(); i++) { for (int j = 0; j < ljuska.size(); j++) { int da = 1; for (int k = 0; k < drva.size(); k++) { if (ccw(ljuska[i], ljuska[j], drva[k]) >= 0) { da = 0; break; } } if (i != j && da) { dist[i][j] = 1; } else { dist[i][j] = 1e6; } } } for (int k = 0; k < ljuska.size(); k++) { for (int i = 0; i < ljuska.size(); i++) { for (int j = 0; j < ljuska.size(); j++) { dist[i][j] = min(dist[i][j], dist[i][k]+dist[k][j]); } } } int mini = 1e9; for (int i = 0; i < ljuska.size(); i++) mini = min(mini, dist[i][i]); cout << 111*(m-drva.size())+mini*20; return 0; }

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

fence.cpp: In function 'int main()':
fence.cpp:41:24: warning: comparison of integer expressions of different signedness: 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   41 |   while (ljuska.size() > kol && ccw(ljuska[(int)ljuska.size()-2], ljuska.back(), holes[i]) >= 0) ljuska.pop_back();
      |          ~~~~~~~~~~~~~~^~~~~
fence.cpp:49:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |   for (int j = 1; j < ljuska.size(); j++) {
      |                   ~~^~~~~~~~~~~~~~~
fence.cpp:64:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   64 |  for (int i = 0; i < ljuska.size(); i++) {
      |                  ~~^~~~~~~~~~~~~~~
fence.cpp:65:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   65 |   for (int j = 0; j < ljuska.size(); j++) {
      |                   ~~^~~~~~~~~~~~~~~
fence.cpp:67:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   67 |    for (int k = 0; k < drva.size(); k++) {
      |                    ~~^~~~~~~~~~~~~
fence.cpp:83:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   83 |  for (int k = 0; k < ljuska.size(); k++) {
      |                  ~~^~~~~~~~~~~~~~~
fence.cpp:84:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   84 |   for (int i = 0; i < ljuska.size(); i++) {
      |                   ~~^~~~~~~~~~~~~~~
fence.cpp:85:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   85 |    for (int j = 0; j < ljuska.size(); j++) {
      |                    ~~^~~~~~~~~~~~~~~
fence.cpp:92:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   92 |  for (int i = 0; i < ljuska.size(); i++) mini = min(mini, dist[i][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...