牛客练习赛102

A 清楚姐姐的学术群

int main() {
	int n = read(), m = read(), a = read(), b = read();
	for(int i = 1; i <= n; i++) people[i].push_back(0);
	for(int i = 1; i <= m; i++) {
		int x = read(), y = read();
		w[i] = {x, y};
		people[x].push_back(y);
	}
	for(int i = 1; i <= m; i++) w[i].second += w[i-1].second;
//	for(int i = 1; i <= m; i++) cout << w[i] << endl;
	for(int i = a; i <= m; i++) {
		int x = w[i].second - w[i-a].second;
	//	cout << x << endl;
		if(x == a) {
			ans[w[i].first]++;
		}
	}
	for(int i = 1; i <= n; i++) {
		int len = people[i].size();
		for(int j = 1; j <= len; j++) people[i][j] += people[i][j-1];
	}
	for(int i = 1; i <= n; i++) {
		int len = people[i].size();
		for(int j = b; j <= len; j++) {
			int x = people[i][j] - people[i][j-b];
			if(x == b) ans[i]++;
		}
	}
	printf("%d\n", ans.size());
	for(auto x : ans) {
		printf("%d ", x.first);
	}
	return 0;
}

B 清楚姐姐带带我

signed main() {
    int n; cin >> n;
	int ans = 0ll;
	for(int i = 1; i <= n; i++) {
        int a, b; cin >> a >> b;
        if(i == 1 || b == 1) ans = (ans + a) % mod;
        else if(ans == 1 && a >= b) ans = (ans + a) % mod;
        else ans = ans * b % mod;
      //  cout << ans << endl;
	}
	ans %= mod;
	printf("%lld\n", ans);
	return 0;
}

C 清楚姐姐的序列
比赛的时候我是按左端点排序,结果过不了,赛后看别人的代码发现按右端点排序能过,其实我当时也想过按右端点排序,但是没去实现一下。

/*
    qwq!
*/
 
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <unordered_map>
using namespace std;
#define pb push_back
#define pu push
#define fi first
#define se second
#define LL long long
#pragma GCC optimize(2)
#define IOS ios::sync_with_stdio(false); std::cin.tie(0),cout.tie(0);
//#define int long long
//#define int __int64
typedef pair<int,int> PII;
const int INF = 0x3f3f3f3f, mod = 1e9 + 7, INF_MAX = 0x7fffffff;
const int N = 2e3 + 10;
//int h[N], e[N], ne[N], idx;
struct node {
    int l, r, x, y;
}w[N];
int ans[N];
 
inline int read () {
    int k=0,f=1;
    char c=getchar ();
    while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar ();}
    while (c>='0'&&c<='9') {k=k*10+c-'0';c=getchar ();}
    return k*f;
}
 
inline void write(int x){
    if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10-'0');
    return;
}
 
inline bool cmp(node a, node b) {
    if(a.r != b.r) return a.r < b.r;
    return a.l < b.l;
}
 
int main() {
    int n = read(), m = read();
    for(int i = 0; i < m; i++) {
        w[i].l = read(), w[i].r = read(), w[i].x = read(), w[i].y = read();
    }
    sort(w, w + m, cmp);
    int k = 0;
    bool success = true;
    for(int i = 0; i < m; i++) {
    	for(int j = w[i].l; j <= w[i].r; j++) {
    		if(!w[i].y) break;
    		if(ans[j]) continue;
    		ans[j] = w[i].x;
    		w[i].y--;
		}
		if(w[i].y) {
			success = false;
			break;
		}
    }   
    if(!success) {
        puts("qcjjddw");
    }else {
        for(int i = 1; i <= n; i++) {
        	if(!ans[i]) cout << 1 << ' ';
        	else cout << ans[i] << ' ';
        }
    }
    return 0;
}
posted @ 2022-09-03 17:37  飘向远方丶  阅读(55)  评论(0编辑  收藏  举报