# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
200281 | wjdqhdhfflavldkem12 | 곡선 자르기 (KOI17_cut) | C++14 | 5 ms | 376 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>
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)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |