Submission #200285

#TimeUsernameProblemLanguageResultExecution timeMemory
200285wjdqhdhfflavldkem12곡선 자르기 (KOI17_cut)C++14
100 / 100
453 ms44472 KiB
#include <stdio.h> #include <vector> #include <utility> #include <algorithm> #include <limits.h> using namespace std; #define LEFT 0 #define RIGHT 1 #define node pair<int, bool> int n, inX, outX; vector<node> LIST; bool compare(node a, node b){ return a.first < b.first; } int main(){ int i; scanf("%d", &n); int xtemp, ytemp, start; int minx = INT_MAX, miny = INT_MAX; vector<int> x, y; for (i = 0; i < n; i++){ scanf("%d %d", &xtemp, &ytemp); x.push_back(xtemp); y.push_back(ytemp); if (xtemp <= minx&&ytemp <= miny){ start = i; minx = xtemp; miny = ytemp; } } for (i = 0; i < start; i++){ x.push_back(x[i]); y.push_back(y[i]); } int size = 0; pair<int, int> temp; for (i = start; i < n+start-1; i++){ if (y[i]<0 && y[i + 1]>0){ size++; temp.first = i; } else if (y[i]>0 && y[i + 1] < 0){ size++; temp.second = i; if (x[temp.first] < x[temp.second]){ LIST.push_back(node(x[temp.first], LEFT)); LIST.push_back(node(x[temp.second], RIGHT)); } else{ LIST.push_back(node(x[temp.first], RIGHT)); LIST.push_back(node(x[temp.second], LEFT)); } } } sort(LIST.begin(), LIST.end(), compare); int count = 0; for (i = 0; i < size; i++){ if (LIST[i].second == LEFT){ count++; if (count == 1) outX++; } else{ count--; if (LIST[i - 1].second == LEFT) inX++; } } printf("%d %d\n", outX, inX); return 0; }

Compilation message (stderr)

cut.cpp: In function 'int main()':
cut.cpp:23:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
  ~~~~~^~~~~~~~~~
cut.cpp:29:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d", &xtemp, &ytemp);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
cut.cpp:25:20: warning: 'start' may be used uninitialized in this function [-Wmaybe-uninitialized]
  int xtemp, ytemp, start;
                    ^~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...