【模拟赛】LuoGu7月月赛

为了Rating!打了场月赛
感觉比以前菜了?

T1

大水题,直接暴力搞,我用上了dfs
结果行末有空格竟然只有50分!!!
诶wa了一次,乐多赛制扣了5分
Code:

#include <bits/stdc++.h>
#define maxn 2010
using namespace std;
int n, a[maxn][maxn];

void dfs(int x1, int y1, int x2, int y2){
	if (x1 == x2) a[x1][y1] = 1; else{
		int l = x2 - x1 + 1;
		l >>= 1;
		dfs(x1, y1 + l, x2 - l, y2);
		dfs(x1 + l, y1, x2, y2 - l);
		dfs(x1 + l, y1 + l, x2, y2);
	}
}

int main(){
	scanf("%d", &n);
	n = 1 << n;
	dfs(1, 1, n, n);
	for (int i = 1; i <= n; printf("%d\n", a[i++][n])) for (int j = 1; j < n; ++j) printf("%d ", a[i][j]);
	return 0;
}
T2

数组模拟链表,我打的可能比较麻烦,还有wa了一发
又扣了5分
Code:

#include <bits/stdc++.h>
#define maxn 100010
using namespace std;
struct node{
	int x, id, l, r;
}a[maxn];
int val[maxn], n, cnt, print[maxn], vis[maxn], id[maxn];

inline int read(){
	int s = 0, w = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') w = -1;
	for (; isdigit(c); c = getchar()) s = (s << 1) + (s << 3) + (c ^ 48);
	return s * w;
}

bool cmp(node x, node y){ return x.x > y.x; }

int main(){
	n = read();
	for (int i = 1; i <= n; ++i) a[i].x = val[i] = read(), a[i].id = i;
	for (int i = 1; i <= n; ++i) a[i].l = i - 1, a[i].r = i + 1;
	sort(a + 1, a + 1 + n, cmp);
	for (int i = 1; i <= n; ++i) id[a[i].id] = i;
	for (int i = 1; i <= n; ++i)
		if (!vis[a[i].id]){
			if (a[i].r < 1 || a[i].r > n) continue;
			print[++cnt] = a[i].x, print[++cnt] = val[a[i].r];
			a[id[a[id[a[i].r]].r]].l = a[i].l, a[id[a[i].l]].r = a[id[a[i].r]].r;
			vis[a[i].r] = 1;
		}
	for (int i = 1; i < cnt; ++i) printf("%d ", print[i]);
	printf("%d\n", print[cnt]);
	return 0;
}
T3

区间逆序对总数
马上反应过来树状数组
离散化+树状数组就行啦

然后这道题非常坑,一开始wa了3个,一直不知道拿错了
在我提交了6次以后终于意识到,爆longlong!
什么鬼?这怎么搞
后来在%%%xzy神仙的帮助下知道可以用__int128,最后一位一位输出就行了

Code:

#include <bits/stdc++.h>
#define maxn 2000010
#define LL long long
using namespace std;
struct node{
	int x, id;
}a[maxn];
int b[maxn], n, p;
LL tree[maxn];
__int128 ans;

inline int read(){
	int s = 0, w = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') w = -1;
	for (; isdigit(c); c = getchar()) s = (s << 1) + (s << 3) + (c ^ 48);
	return s * w;
}

bool cmp(node x, node y){ return x.x < y.x; }
void update(int x, int y){ for (; x; x -= x & -x) tree[x] += y; }
LL query(int x){ LL sum = 0; for (; x <= p; x += x & -x) sum += tree[x]; return sum; }

inline void write(__int128 x){
    if(x<0){putchar('-');x=~(x-1);}
    int s[200],top=0;
    while(x){s[++top]=x%10;x/=10;}
    if(!top)s[++top]=0;
    while(top)putchar(s[top--]+'0');
    puts("");
}

signed main(){
	n = read();
	for (int i = 1; i <= n; ++i) a[i].x = read(), a[i].id = i;
	sort(a + 1, a + 1 + n, cmp);
	a[0].x = a[1].x - 1;
	p = 0;
	for (int i = 1; i <= n; ++i) b[a[i].id] = a[i].x == a[i - 1].x ? p : ++p;
	for (int i = 1; i <= n; ++i){
		ans += query(b[i] + 1) * 1LL * (n - i + 1);
		update(b[i], i);
	}
	write(ans);
	return 0;
}
T4

直接打了个暴力去吃饭了
没什么可说的,感觉挺难
Code:

#include <bits/stdc++.h>
#define maxn 1000010
using namespace std;
int f[maxn], cnt, a[maxn], vis[1000][1000], l[1000], r[1000], n, ans;

inline int read(){
	int s = 0, w = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') w = -1;
	for (; isdigit(c); c = getchar()) s = (s << 1) + (s << 3) + (c ^ 48);
	return s * w;
}

int get(int k){ return k == f[k] ? k : f[k] = get(f[k]); }

void Do(){
	int sum = 0;
	for (int i = 1; i <= cnt; ++i) f[a[i]] = a[i];
	for (int i = 1; i <= cnt; ++i)
		for (int j = i + 1; j <= cnt; ++j)
			if (vis[a[i]][a[j]]){
				++sum;
				int s1 = get(a[i]), s2 = get(a[j]);
				if (s1 != s2) f[s1] = s2;
			}
	if (sum != cnt - 1) return;
	for (int i = 2; i <= cnt; ++i) if (get(a[i]) != get(a[1])) return;
	++ans;
}

void dfs(int k){
	if (k > n) Do(); else{
		a[++cnt] = k;
		dfs(k + 1);
		--cnt;
		dfs(k + 1);
	}
}

int main(){
	n = read();
	for (int i = 1; i <= n; ++i) l[i] = read(), r[i] = read();
	for (int i = 1; i <= n; ++i)	
		for (int j = 1; j <= n; ++j){
			int L = max(l[i], l[j]), R = min(r[i], r[j]);
			if (L <= r[i] && R >= l[i] && L <= r[j] && R >= l[j]) vis[i][j] = vis[j][i] = 1;
		}
	dfs(1);
	printf("%d\n", ans);
	return 0;
}

感觉挺简单的,不过今天心情有点浮躁所以没打好
继续加油

### 关于第十六届蓝桥杯Web组模拟赛的信息 #### 比详情与规则 对于参加者来说,了解具体事安排至关重要。尽管目前尚未提供关于第十六届蓝桥杯Web应用开发竞的具体细节[^1],通常情况下,这类比会遵循一定的模式。一般而言,比分为多个阶段,包括但不限于初、决等不同环节。参选手需按照官方发布的指南完成在线报名流程,并按时提交作品。 #### 参加方法 为了参与此类活动,建议密切关注官方网站的通知公告以及社交媒体平台上的最新动态。一般来说,参与者可以通过访问蓝桥杯官网注册账号并填写必要的个人信息来完成报名过程。之后,在规定的时间内登录指定系统解答试题或上传项目成果即可[^2]。 #### 练习资源推荐 准备期间可以利用多种途径加强技能训练。除了官方提供的OJ题库外,还可以参考其他类似的编程挑战网站如LeetCode、Luogu等以拓宽视野和提高解题能力。特别值得注意的是页面布局类题目往往占据重要位置,因此应加强对HTML/CSS/JavaScript等相关技术的学习实践。 ```html <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Practice Layout</title> <style> /* 示例样式 */ .container { display: flex; justify-content: center; align-items: center; height: 100vh; } .box { width: 200px; height: 200px; background-color: lightblue; } </style> </head> <body> <div class="container"> <div class="box"></div> </body> </html> ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值