# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
200285 | wjdqhdhfflavldkem12 | 곡선 자르기 (KOI17_cut) | C++14 | 453 ms | 44472 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |