Day1-T1
Describe:普通前缀和(当然有升级版的题目,范围3000+)
code:
#include<bits/stdc++.h> #define maxn 1010 #define INF 1010010101 #define eps 1e-9 #define rep1(x,y) for(register int i=x;i<=y;i++) #define rep2(x,y) for(register int j=x;j<=y;j++) #define rep3(x,y) for(register int k=x;k<=y;k++) #define rep4(x,y) for(register int l=x;l<=y;l++) using namespace std; typedef long long LL; typedef unsigned long long ULL; typedef double db; bool f[55][55]; LL r,c,n,K,s[55][55]; LL ans,now; int x,y; inline int read(){ int ret=0,f=1;char ch=getchar(); while (ch<'0'||ch>'9') {if (ch=='-') f=-f;ch=getchar();} while (ch>='0'&&ch<='9') ret=ret*10+ch-'0',ch=getchar(); return ret*f; } inline void write(LL x){ if(x<0){putchar('-'),write(-x);return;} if(x/10)write(x/10);putchar(x%10+'0'); } inline double Read(){ double X=0,Y=1.0;int w=0;char ch=0; while(!isdigit(ch)){w|=ch=='-';ch=getchar();} while(isdigit(ch))X=X*10+(ch^48),ch=getchar(); ch=getchar(); while(isdigit(ch)) X+=(Y/=10)*(ch^48),ch=getchar(); return w?-X:X; } int main(){ freopen("Orchestra.in","r",stdin); freopen("Orchestra.out","w",stdout); r=read();c=read();n=read();K=read(); rep1(1,n)x=read(),y=read(),f[x][y]=1; rep1(1,r)rep2(1,c){s[i][j]=s[i-1][j]+f[i][j]+s[i][j-1]-s[i-1][j-1];} for(int i=1;i<=r;i++){ for(int j=1;j<=c;j++){ for(int k=i;k<=r;k++){ for(int l=j;l<=c;l++){ now=s[k][l]-s[i-1][l]-s[k][j-1]+s[i-1][j-1]; if(now>=K)ans++; } } } } write(ans); return 0; }