其他分享
首页 > 其他分享> > CSP202104-2领域均值

CSP202104-2领域均值

作者:互联网

 

 

 

 


思路清晰就好,不是很难只是有点复杂。 

 

 

 

 


#include<bits/stdc++.h>
#define atest
using namespace  std;
int n,l,r,t;
int mapp[601][601];
int main(){
    cin>>n;
    cin>>l;
    cin>>r;
    cin>>t;

    int i,j,k;
    for(i=0;i<n;i++){
        for(j=0;j<n;j++){
            cin>>mapp[i][j];
        }
    }
    int s=0;
    int res=0;
    vector<int> col;
    for(i=0;i<n;i++){
            s=0;
            col.clear();
            for(k=0;k<n;k++){
                s=0;
#ifdef test
                cout<<min(r,n-i-1)+1+min(r,i)<<"hanggao"<<endl;
#endif
                for(j=0;j<min(r,n-i-1)+1+min(r,i);j++){
                    s+=mapp[max(0,i-r)+j][k];
                }
                col.push_back(s);
#ifdef test
                cout<<s<<"pushed\n";
#endif
            }
            //col.push_back(0);
            //initialize col
            s=0;
            for(j=0;j<r+1;j++){
                s+=col[j];
            }
            for(j=0;j<n;j++){
#ifdef test
                cout<<i<<" "<<j<<" "<<s<<" "<<(min(j,r)+min(r,n-j-1))*(min(r,n-i-1)+1+min(r,i))<<endl;

#endif
                if(s<=(min(j,r)+1+min(r,n-j-1))*(min(r,n-i-1)+1+min(r,i))*t) res+=1;
                if(j-r>=0) s-=col[j-r];
                if(j+r<n+1) s+=col[j+r+1];
            }

    }
    cout<<res;
}

  

 

标签:601,int,res,CSP202104,均值,cin,领域,mapp,col
来源: https://www.cnblogs.com/hyffff/p/14722660.html