正文
增加 17 行删除 17 行
159 行未改动全部展开16016116216316416516616716816917017117217317417517625 行未改动20220320420520620720820921041 行未改动25225325425525625725825926026126226326426526626726826927027160 行未改动3323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743757 行未改动3833843853863873883893903913923933943 行未改动159 行未改动全部展开int main(){cin>>C;cin>>n>>m>>q;int line_cnt=0;int x_cnt=0;for(int K=1;K<=q;K++){ll t,x1,y1,x2,y2;cin>>t>>x1>>y1>>x2>>y2;if(t==1)//将一条横线染为黑色{line[++line_cnt]={y1,x1,x2+1,1};line[++line_cnt]={y1+1,x1,x2+1,-1};25 行未改动//离散化sort(x+1,x+x_cnt+1);int m_dis=unique(x+1,x+x_cnt+1)-x-1;sort(line+1,line+line_cnt+1);//扫描线板子line[0].y=0;for(int i=1;i<=line_cnt;i++){41 行未改动long long n, m;int q;cin >> c >> n >> m >> q;for (int i = 0; i < q; i++) {int t; long long x1, y1, x2, y2;cin >> t >> x1 >> y1 >> x2 >> y2;if (t == 1) {for (long long x = x1; x <= x2; x++) {board[y1][x] = true;}}}long long ans = 0;//其实这个循环可以省,但是我懒for (int y = 1; y <= n; y++) {for (long long x = 1; x <= m; x++) {if (board[y][x]) ans++;60 行未改动return x.l < y.l;}int main() {int c;cin >> c;long long n, m;int q;cin >> n >> m >> q;int cnt = 0;for (int i = 0; i < q; i++) {int t; long long x1, y1, x2, y2;cin >> t >> x1 >> y1 >> x2 >> y2;if (t == 1) {seg[cnt++] = {y1, x1, x2};}}//按行号排序,让同一行的区间连续sort(seg, seg + cnt, cmp1);long long ans = 0;//遍历每一行for (int i = 0; i < cnt; ) {int j = i;// 找到同一行的区间,j指向下一行的开头while (j < cnt && seg[j].h == seg[i].h) {j++;}//按左端点排序int len = j - i;for (int k = 0; k < len; k++) {tmp[k] = seg[i + k];}sort(tmp, tmp + len, cmp2);//合并区间并累加长度long long curL = tmp[0].l;long long curR = tmp[0].r;for (int k = 1; k < len; k++) {7 行未改动curR = R;}}ans += curR - curL + 1;//别忘了最后一个区间i = j;// 跳到下一行}cout << ans << endl;return 0;}```3 行未改动159 行未改动全部展开16016116216316416516616716816917017117217317417517625 行未改动20220320420520620720820921041 行未改动25225325425525625725825926026126226326426526626726826927027160 行未改动3323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743757 行未改动3833843853863873883893903913923933943 行未改动159 行未改动全部展开int main(){cin>>C;cin>>n>>m>>q;int line_cnt=0;int x_cnt=0;for(int K=1;K<=q;K++){ll t,x1,y1,x2,y2;cin>>t>>x1>>y1>>x2>>y2;if(t==1)//将一条横线染为黑色{line[++line_cnt]={y1,x1,x2+1,1};line[++line_cnt]={y1+1,x1,x2+1,-1};25 行未改动//离散化sort(x+1,x+x_cnt+1);int m_dis=unique(x+1,x+x_cnt+1)-x-1;sort(line+1,line+line_cnt+1);//扫描线板子line[0].y=0;for(int i=1;i<=line_cnt;i++){41 行未改动long long n, m;int q;cin >> c >> n >> m >> q;for (int i = 0; i < q; i++) {int t; long long x1, y1, x2, y2;cin >> t >> x1 >> y1 >> x2 >> y2;if (t == 1) {for (long long x = x1; x <= x2; x++) {board[y1][x] = true;}}}long long ans = 0;//其实这个循环可以省,但是我懒for (int y = 1; y <= n; y++) {for (long long x = 1; x <= m; x++) {if (board[y][x]) ans++;60 行未改动return x.l < y.l;}int main() {int c;cin >> c;long long n, m;int q;cin >> n >> m >> q;int cnt = 0;for (int i = 0; i < q; i++) {int t; long long x1, y1, x2, y2;cin >> t >> x1 >> y1 >> x2 >> y2;if (t == 1) {seg[cnt++] = {y1, x1, x2};}}//按行号排序,让同一行的区间连续sort(seg, seg + cnt, cmp1);long long ans = 0;//遍历每一行for (int i = 0; i < cnt; ) {int j = i;// 找到同一行的区间,j指向下一行的开头while (j < cnt && seg[j].h == seg[i].h) {j++;}//按左端点排序int len = j - i;for (int k = 0; k < len; k++) {tmp[k] = seg[i + k];}sort(tmp, tmp + len, cmp2);//合并区间并累加长度long long curL = tmp[0].l;long long curR = tmp[0].r;for (int k = 1; k < len; k++) {7 行未改动curR = R;}}ans += curR - curL + 1;//别忘了最后一个区间i = j;// 跳到下一行}cout << ans << endl;return 0;}```3 行未改动