18寒假第六測

2022-05-29 05:54:14 字數 2291 閱讀 2724

第一題:乘法修改的線段樹

一定不能將change,modify分類討論定兩個標記,會有順序影響

lazy標記一定要long long,又忘了。。。

**和上一次差不多

第二題:離散暴力,也可以掃瞄線

離散時要將格仔對映成點,不然會出現以下情況:

算橫著的小矩形寬就是2,算黃色面積寬還是2,因為沒有2讓3去減

如果對映成點,就像這樣,,放圖比較好理解,就像掃瞄線,乙個葉子節點存的是乙個左閉右開的區間

也可以離散+掃瞄線,但還沒寫出來

#include using

namespace

std;

#define maxn 1005

int disx[maxn*2],disy[maxn*2],xs[maxn*2],xe[maxn*2],ys[maxn*2],ye[maxn*2

];int

totx,toty;

bool st[maxn*2][maxn*2

];void read(int &x)

while(s>='

0'&&s<='9')

x*=f;

}int

main()

sort(disx + 1, disx + 1 +totx);

sort(disy + 1, disy + 1 +toty);

totx = unique(disx + 1, disx + 1 + totx) - disx - 1

; toty = unique(disy + 1, disy + 1 + toty) - disy - 1

;

for(int k = 1; k <= n; k++)

long

long ans = 0

;

for(int i = 1; i <= totx; i++)

for(int j = 1; j <= toty; j++)

if(st[i][j])

ans += 1ll * (disx[i] - disx[i - 1]) * (disy[j] - disy[j - 1

]); printf(

"%i64d\n

",ans);

return0;

}

第三題:可持久化陣列,每次建樹logn的空間複雜度,不改變原來的版本

pool大小為n*2+q*logn,q為詢問次數

#include using

namespace

std;

#define maxn 100005

#define ll long long

inta[maxn],n,m,s;

void read(int &x)

while(s>='

0'&&s<='9')

x*=f;

}struct

nodepool[maxn * 32],*tail = pool, *root[maxn];//

?node * build(int l = 1,int r =n)

return

nd;}

#define ls nd->ls, l, m

#define rs nd->rs, m+1, rnode * modify(int delta, int pos, node *nd, int l = 1, int r =n)

if(pos >m)

}return

nnd;

}int query(int pos, node *nd, int l = 1, int r =n )

}node * print(int pos,node *nd)

intmain()

else

if(opt[0] == 'm'

)

else}}

寒假OS學習第六天

外設的所有中斷都由中斷控制晶元8259a匯集後連線到cpu的intr引腳 8259a pic每一片能管理8個中斷源。使用級聯功能 時鐘中斷連線在主片的ir0引腳,鍵盤中斷連線在ir1引腳 因為0 31號中斷是cpu自己用的,所以ir0開始對應的就是32號中斷號 要完成中斷請求,首先要進行初始化 st...

MySQL第六章小測

正確答案但是我不會 不會不確定 1 關係模式存在問題 更新異常 插入異常 刪除異常 2 規範化理論是關聯式資料庫進行邏輯設計的理論依據,根據這個理論,關聯式資料庫種的關係必須滿足,每乙個屬性都是 不可分解的 3 關係模式r,若每乙個決定因素都包含碼,則r最高達到 bcnf 若關百系模式r中的屬性全是...

寒假學習day18

今天學習了 布局的stretchcolumns 拉伸列 流程 在tablelayout中設定了四個按鈕,接著在最外層的tablelayout中新增以下屬性 android stretchcolumns 1 設定第二列為可拉伸列,讓該列填滿這一行所有的剩餘空間,如下 android id id tab...