程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> C語言 >> C++ >> 關於C++ >> 4418: [Shoi2013]扇形面積並|二分答案|樹狀數組

4418: [Shoi2013]扇形面積並|二分答案|樹狀數組

編輯:關於C++

為何感覺SHOI的題好水。。。又是一道SB題
從左到右枚舉每一個區間,遇到一個扇形的左區間就+1,遇到右區間就-1,然後再樹狀數組上2分答案,還是不會碼log的。。SHOI2013似乎還有一道題發牌也是類似的維護方法。。

#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define ll long long
#define mod 999911659 //2 3 4679 35617
#define N 500001
using namespace std;
int sc()
{
    int i=0,f=1; char c=getchar();
    while(c>'9'||c<'0'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9')i=i*10+c-'0',c=getchar();
    return i*f;
}
struct W{int p,r,x;}a[N];
long long ans;
int n,tot,mx,k,m,tr[N];
bool cmp(W a,W b)
{
    return a.p>1;
        if(ask(mid)>=k)ans=mid,l=mid+1;
        else r=mid-1;
    }
    return ans;
}
int main()
{
    n=sc();m=sc(),k=sc();
    for(int i=1;i<=n;i++)
    {
        int x=sc(),l=sc(),r=sc();mx=max(mx,x);
        a[++tot].p=l,a[tot].r=x,a[tot].x=1;
        a[++tot].p=r,a[tot].r=x,a[tot].x=-1;
        if(l>r)
            a[++tot].p=-m,a[tot].r=x,a[tot].x=1;
    }
    sort(a+1,a+tot+1,cmp);
    int now=1;
    for(int i=-m;i
  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved