CF1142C U2
生活随笔
收集整理的這篇文章主要介紹了
CF1142C U2
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
題目鏈接:洛谷?codeforces
$y>x^2+bx+c$也就是$y-x^2>bx+c$
左邊是點,右邊是直線.
維護上凸包.
雖然這么簡單但就是做不出來。
1 #include<cstdio> 2 #include<algorithm> 3 #define Rint register int 4 using namespace std; 5 typedef long long LL; 6 const int N = 100003; 7 struct Point { 8 LL x, y; 9 inline Point(LL _x = 0, LL _y = 0): x(_x), y(_y){} 10 inline Point operator - (const Point &o) const {return Point(x - o.x, y - o.y);} 11 inline LL operator * (const Point &o) const {return x * o.y - y * o.x;} 12 inline bool operator < (const Point &o) const {return x < o.x || x == o.x && y > o.y;} 13 } p[N], q[N], stk[N]; 14 int n, m, top; 15 int main(){ 16 scanf("%d", &n); 17 for(Rint i = 1;i <= n;i ++){ 18 scanf("%I64d %I64d", &p[i].x, &p[i].y); 19 p[i].y -= p[i].x * p[i].x; 20 } 21 sort(p + 1, p + n + 1); 22 q[m = 1] = p[1]; 23 for(Rint i = 2;i <= n;i ++) if(p[i].x != p[i - 1].x) q[++ m] = p[i]; 24 for(Rint i = 1;i <= m;i ++){ 25 while(top > 1 && (stk[top] - stk[top - 1]) * (q[i] - stk[top - 1]) >= 0) -- top; 26 stk[++ top] = q[i]; 27 } 28 printf("%d\n", top - 1); 29 } // nantf tai qiang le! CF1142C?
轉(zhuǎn)載于:https://www.cnblogs.com/AThousandMoons/p/10662648.html
總結(jié)
以上是生活随笔為你收集整理的CF1142C U2的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: MYSQL.版本查看-LINUX
- 下一篇: ssm学习的第一个demo---crm(