Submission #200281

#TimeUsernameProblemLanguageResultExecution timeMemory
200281wjdqhdhfflavldkem12곡선 자르기 (KOI17_cut)C++14
0 / 100
5 ms376 KiB
#include <stdio.h> #include <vector> #include <utility> #include <algorithm> 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; vector<int> x, y; for (i = 0; i < n; i++){ scanf("%d %d", &xtemp, &ytemp); x.push_back(xtemp); y.push_back(ytemp); } x.push_back(x[0]); y.push_back(y[0]); x.push_back(x[1]); y.push_back(y[1]); int size = 0; for (i = 0; i < n; i++){ if ((y[i]>0 && y[i + 1]<0) || (y[i]<0 && y[i + 1]>0)){ if (size != 0 && size % 2 == 1){ LIST.push_back(node(x[i], !LIST[size-1].second)); size++; } else if (x[i + 1]<x[i + 2]){ size++; LIST.push_back(node(x[i], LEFT)); } else{ size++; LIST.push_back(node(x[i], RIGHT)); } } } /* for (i = 0; i < size; i++){ printf("%d\t%d\n", LIST[i].first, LIST[i].second); } */ sort(LIST.begin(), LIST.end(), compare); /* printf("\n"); for (i = 0; i < size; i++){ printf("%d\t%d\n", LIST[i].first, LIST[i].second); } */ int count = 0; for (i = 0; i < LIST.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:66:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (i = 0; i < LIST.size(); i++){
              ~~^~~~~~~~~~~~~
cut.cpp:22:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
  ~~~~~^~~~~~~~~~
cut.cpp:27:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d", &xtemp, &ytemp);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...