zoukankan      html  css  js  c++  java
  • usOJ

    博主的 BiBi 时间

    先开始做了个 (mathcal O(n imes q)) 的,以为 (3e8) 可以艹过去。。。然后就凉了。

    ( ext{Description})

    传送门

    ( ext{Solution})

    维护两个差分数组分成 (add,del),画个图就明白了。

    (add) 维护竖的,(del) 维护斜的。最后数组每一行从左到右累加,正好在竖线加 (s),过了三角形减 (s)

    ( ext{Code})

    #include <cstdio>
    
    #define rep(i,_l,_r) for(register signed i=(_l),_end=(_r);i<=_end;++i)
    #define fep(i,_l,_r) for(register signed i=(_l),_end=(_r);i>=_end;--i)
    #define erep(i,u) for(signed i=head[u],v=to[i];i;i=nxt[i],v=to[i])
    #define efep(i,u) for(signed i=Head[u],v=To[i];i;i=Nxt[i],v=To[i])
    #define print(x,y) write(x),putchar(y)
    
    template <class T> inline T read(const T sample) {
    	T x=0; int f=1; char s;
    	while((s=getchar())>'9'||s<'0') if(s=='-') f=-1;
    	while(s>='0'&&s<='9') x=(x<<1)+(x<<3)+(s^48),s=getchar();
    	return x*f;
    }
    template <class T> inline void write(const T x) {
    	if(x<0) return (void) (putchar('-'),write(-x));
    	if(x>9) write(x/10);
    	putchar(x%10^48);
    }
    template <class T> inline T Max(const T x,const T y) {if(x>y) return x; return y;}
    template <class T> inline T Min(const T x,const T y) {if(x<y) return x; return y;}
    template <class T> inline T fab(const T x) {return x>0?x:-x;}
    template <class T> inline T Gcd(const T x,const T y) {return y?Gcd(y,x%y):x;}
    template <class T> inline T Swap(T &x,T &y) {x^=y^=x^=y;}
    
    typedef long long ll;
    
    const int maxn=2005;
    
    int n;
    ll add[maxn][maxn],del[maxn][maxn],a[maxn][maxn],ans;
    
    int main() {
    	int r,c,l,s;
    	n=read(9);
    	for(int t=read(9);t;--t) {
    		r=read(9),c=read(9),l=read(9),s=read(9);
    		add[r][c]+=s,add[r+l][c]-=s;
    		del[r][c+1]+=s,del[r+l][c+l+1]-=s; 
    	}
    	rep(j,1,n) rep(i,1,n) add[i][j]+=add[i-1][j];
    	rep(i,1,n) rep(j,1,n) {
    		del[i][j]+=del[i-1][j-1];
    		a[i][j]+=a[i][j-1]+add[i][j]-del[i][j];
    		ans^=a[i][j];
    	}
    	print(ans,'
    ');
    	return 0;
    }
    
  • 相关阅读:
    Javascript事件处理进阶
    Restful API设计指南
    Git&GitHub
    Linux补充
    堡垒机
    Python发送邮件
    js获取当前页面url网址信息
    高并发的秒杀系统
    CMDB开发
    Tornado
  • 原文地址:https://www.cnblogs.com/AWhiteWall/p/13566813.html
Copyright © 2011-2022 走看看