Codeforces Round #427 C

Posted %%%%%

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Codeforces Round #427 C相关的知识,希望对你有一定的参考价值。

Star sky

题意:在坐标系上有一些星星,坐标大于1小于100,每颗星星初始亮度为si,每过1s亮度+1,当亮度>c的时候变为0,c<=10,q个询问,求每次在给定的矩形区域内所有星星的亮度

思路:处理出每一个星星每个事件的亮度,然后再对应到坐标(一个坐标可能有多颗星星),处理出x或y轴的前缀和,每次询问对区域内的亮度求和就是

AC代码:

#include "iostream"
#include "string.h"
#include "stack"
#include "queue"
#include "string"
#include "vector"
#include "set"
#include "map"
#include "algorithm"
#include "stdio.h"
#include "math.h"
#pragma comment(linker, "/STACK:102400000,102400000")
#define ll long long
#define endl ("\n")
#define bug(x) cout<<x<<" "<<"UUUUU"<<endl;
#define mem(a,x) memset(a,x,sizeof(a))
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define ft (frist)
#define sd (second)
#define lrt (rt<<1)
#define rrt (rt<<1|1)
using namespace std;
const long long INF = 1e18+1LL;
const int inf = 1e9+1e8;
const int N=1e5+100;
const ll mod=1e9+7;

///CCCC
int n,q,c;
int s[15][105][105];
struct Node{
    int x,y,s;
};
Node ar[15][N];
int main(){
    ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    cin>>n>>q>>c;
    int x,y,z;
    for(int i=1; i<=n; ++i){
        cin>>x>>y>>z;
        ar[0][i].x=x, ar[0][i].y=y, ar[0][i].s=z;
    }
    for(int i=1; i<=c; ++i){
        for(int j=1; j<=n; ++j){
            ar[i][j]=ar[0][j];
        }
    }
    for(int i=1; i<=c; ++i){
        for(int j=1; j<=n; ++j){
            ar[i][j].s+=i;
            ar[i][j].s%=c+1;
        }
    }
    for(int i=0; i<=c; ++i){
        for(int j=1; j<=n; ++j){
            x=ar[i][j].x, y=ar[i][j].y;
            s[i][x][y]+=ar[i][j].s;
        }
    }
    for(int i=0; i<=c; ++i){
        for(int j=1; j<=100; ++j){
            for(int k=2; k<=100; ++k){
                s[i][j][k]+=s[i][j][k-1];
            }
        }
    }
    int x1,y1,x2,y2,t;
    while(q--){
        cin>>t>>x1>>y1>>x2>>y2;
        t%=c+1;
        ll ans=0;
        for(int i=x1; i<=x2; ++i){
            ans += s[t][i][y2]-s[t][i][y1-1];
        }
        cout<<ans<<endl;
    }
    return 0;
}

 

以上是关于Codeforces Round #427 C的主要内容,如果未能解决你的问题,请参考以下文章

Codeforces Round #427 B

Codeforces Round #427 A

Codeforces Round #427 (Div. 2) D. Palindromic characteristics

codeforces round #427 div2

Codeforces Round #427 (Div. 2) D dp

Codeforces Round #427 (Div. 2)