题解 | #彩虹涂鸦#

彩虹涂鸦

https://www.nowcoder.com/practice/507cf29e541545c18968fd0436ad8b23

// 模拟!
#include <bits/stdc++.h> 

using namespace std;

int main(){
    int n,q,l,r,k,pos;
    cin >> n >> q;
    vector<int> a(n+1,0),c(n+1,0),col;
    int opt,mx;
    map<int,int> cnt;
    
    while(q--){
        cin >> opt;
        if(opt == 1){
            cin >> l >> r >> k;
            col.resize(k);
            for(int i = 0; i < k; ++i) cin >> col[i];
            pos = 0;
            for(int i = l; i <= r; ++i){
                int d = col[pos];
                pos = (pos+1)%k;
                if(a[i] != d) ++c[i];
                a[i] = d;
            }
            
        }else if(opt == 2){
            cin >> pos;
            cout << c[pos] << " " << a[pos] << endl;
            
        }else {
            
            cin >> l >> r;
            cnt.clear();
            for(int i = l; i <= r; ++i) cnt[a[i]] ++;
            mx = 0;
            for(auto x : cnt) mx = max(mx,x.second);
            cout << mx << endl;
        }
        
    }
    
    return 0;
}

全部评论

相关推荐

不愿透露姓名的神秘牛友
07-11 11:21
被夸真的超级开心,好可爱的姐姐
码农索隆:老色批们不用脑补了,我把金智妮的图找来了查看图片
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
07-08 14:08
点赞 评论 收藏
分享
见见123:简历没有啥问题,是这个社会有问题。因为你刚毕业,没有工作经历,现在企业都不要没有工作经历的。社会病了。
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务