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 <algorithm>
using namespace std;
typedef struct vertex { int x,y; } vertex;
int xcomp (vertex a,vertex b) { return (a.x<b.x)?1:0; }
int ycomp (vertex a,vertex b) { return (a.y<b.y)?1:0; }
int main(void)
{
vertex strawman[200001];
int snum, res=0;
scanf ("%d", &snum);
for (int i=0; i<snum; i++) scanf("%d%d", &strawman[i].x, &strawman[i].y);
sort (strawman, strawman+snum, xcomp);
for (int i=0; i<snum; i++) strawman[i].x=i;
sort (strawman, strawman+snum, ycomp);
for (int i=0; i<snum; i++) strawman[i].y=i;
int temp;
for (int i=0;i<snum;i++) {
temp=2147483647;
for (int j=i+1;j<snum;j++) if (strawman[j].x<=temp && strawman[j].x>strawman[i].x) {
temp=strawman[j].x;
res++;
}
}
printf("%d",res);
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |