QBXT模拟赛1

总结

期望得分:\(100 + 80 + 10 = 190\)

实际得分:\(90 + 80 + 10 = 180\)

这是在清北的第一场考试,也是在清北考的最高的一次了吧。。本来以为能拿\(190\)的,没想到强者太多,\(AK\)的一群,\(200\)分大众分。。我好菜

思路&&代码

T1

\(T1\)是个简单题,却因为\(1-1=0\)这个点忘记去除前导零而失去了\(10\)分,以后要多对拍,多注意细节

#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std; const int N = 1e5 + 11; inline int read() {
char c = getchar();
int x = 0, f = 1;
for( ; !isdigit(c); c = getchar()) if(c == '-') f = -1;
for( ; isdigit(c); c = getchar()) x = (x << 3) + (x << 1) + (c ^ 48);
return x * f;
} char s[N];
string a;
int len, now, whe, pos; int main() {
scanf("%s", s + 1);
len = strlen(s + 1), now = s[1] - '0', whe = 1, pos = 1;
for(int i = 2, x; i <= len; i++) {
x = s[i] - '0';
if(x > now) {
now = x;
whe = i;
pos = i;
}
else if(x == now) pos = i;
if(x < now) break;
}
if(whe == len || pos == len) return cout << (s + 1) << '\n', 0;
for(int i = 1; i < whe; i++) a += s[i];
if(s[whe] - 1 != '0') a += s[whe] - 1;
for(int i = whe + 1; i <= len; i++) a += '9';
cout << a;
return 0;
}

T2

看式子不懂,之后手算一下发现就是个逆序对,进而发现可以转化为求哪些区间包含这对逆序对,然后这对逆序对的值乘以区间个数,式子如下

\[\sum_j a_j * (n - j + 1) *\sum_{a_i > a_j, i < j} a_i * i
\]

后面的可以用数据结构维护,发现模数是\(1e12+7\),两个\(10^12\)的数相乘会爆\(long\ long\),所以要用快速乘

然后就做完了

#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define lowbit(x) (x & -x)
#define int long long
using namespace std; const int N = 5e5 + 11;
const int mod = 1e12 + 7; inline int read() {
char c = getchar();
int x = 0, f = 1;
for( ; !isdigit(c); c = getchar()) if(c == '-') f = -1;
for( ; isdigit(c); c = getchar()) x = (x << 3) + (x << 1) + (c ^ 48);
return x * f;
} int n;
int a[N], ans = 0;
int b[N], p[N], f[N]; inline int mul(int a, int b, int res = 0) {
while(b) {
if(b & 1) ans = (ans + a) % mod;
a = a + a % mod; b >>= 1;
}
return res;
} inline int query(int x) {
int ans = 0;
for(int i = x; i; i -= lowbit(i)) ans = (ans + p[i]) % mod;
return ans;
} const int MAX = 1e5; inline void add(int x, int val) {
for(int i = x; i <= MAX; i += lowbit(i)) p[i] = (p[i] + val) % mod;
return;
} signed main() {
n = read();
for(int i = 1; i <= n; i++) b[i] = a[i] = read();
sort(b + 1, b + 1 + n);
for(int i = 1; i <= n; i++) f[i] = lower_bound(b + 1, b + 1 + n, a[i]) - b;
for(int i = 1; i <= n; i++) {
int now = query(n) - query(f[i]);
now = (now % mod + mod) % mod;
ans = ans + mul(now * (n - i + 1), a[i]);
ans = (ans % mod + mod) % mod;
add(f[i], a[i] * i);
}
ans = (ans % mod + mod) % mod;
cout << ans << '\n';
return 0;
}

T3

直接用线段树扫描线就\(over\)了

还有一种神奇做法。。

#include <map>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define max(a, b) (a > b ? a : b)
#define min(a, b) (a < b ? a : b)
#define PII pair<int, int>
#define mk(x, y) make_pair(x, y)
using namespace std; const int N = 5e4 + 11;
const int M = 1e6 + 11;
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f; inline int read() {
char c = getchar();
int x = 0, f = 1;
for( ; !isdigit(c); c = getchar()) if(c == '-') f = -1;
for( ; isdigit(c); c = getchar()) x = (x << 3) + (x << 1) + (c ^ 48);
return x * f;
} int n, m, a[N], b[N], c[N], d[N];
int mina, minb, maxc, maxd; map<pair<int, int>, int> mp; int main() {
int T = read();
while(T--) {
n = read();
mina = minb = INF;
maxc = maxd = -INF;
mp.clear();
for(int i = 1; i <= n; i++) {
a[i] = read(), b[i] = read(), c[i] = read(), d[i] = read();
mina = min(mina, a[i]);
minb = min(minb, b[i]);
maxc = max(maxc, c[i]);
maxd = max(maxd, d[i]);
mp[mk(a[i], b[i])]++;
mp[mk(a[i], d[i])]++;
mp[mk(c[i], b[i])]++;
mp[mk(c[i], d[i])]++;
}
int cnt = 0;
if(mp[mk(mina, minb)] == 1) cnt++;
if(mp[mk(mina, maxd)] == 1) cnt++;
if(mp[mk(maxc, minb)] == 1) cnt++;
if(mp[mk(maxc, maxd)] == 1) cnt++;
if(cnt != 4) {
puts("Guguwansui");
continue;
}
cnt = 0;
for(int i = 1; i <= n; i++) {
if(mp[mk(a[i], b[i])] == 1) cnt++;
if(mp[mk(a[i], d[i])] == 1) cnt++;
if(mp[mk(c[i], b[i])] == 1) cnt++;
if(mp[mk(c[i], d[i])] == 1) cnt++;
}
if(cnt == 4) puts("Perfect");
else puts("Guguwansui");
}
return 0;
}
//这题太神了我不会。

QBXT模拟赛1的更多相关文章

  1. QBXT模拟赛2

    总结 期望得分:\(100 + 40 + 0 = 140\) 实际得分:\(0 + 0 + 0 = 0\) 鬼知道为什么我代码没有交上..自测\(10 + 50 + 0\)--这是心态爆炸的一场考试 ...

  2. 4.28 QBXT模拟赛

    NOIP2016提高组模拟赛 ——By wangyurzee7 中文题目名称 迷妹 膜拜 换数游戏 英文题目与子目录名 fans mod game 可执行文件名 fans mod game 输入文件名 ...

  3. 2017.10.3 QBXT 模拟赛

    题目链接 T1 模拟 #include <cstring> #include <cstdio> #define N 105000 int L,R; char s[N]; int ...

  4. 2017.10.7 QBXT 模拟赛

    题目链接 T1 容斥原理,根据奇偶性进行加减 #include<iostream> #include<cstdio> using namespace std; typedef ...

  5. 2017.10.6 QBXT 模拟赛

    题目链接 T1 Sort 一下与原数组比较 ,若有两个数或者没有数发生位置交换 ,则输出YES ,否则输出NO #include <algorithm> #include <ccty ...

  6. 2017.10.5 QBXT 模拟赛

    题目链接 T1 从小到大排序,用sum记录前缀和,然后枚举1~n个数 ,如果当前的前缀和 + 1小于a[i]的话 那么 sum + 1永远不可能拼出来 直接输出sum + 1 ,否则统计前缀和.最后如 ...

  7. 2017.10.4 QBXT 模拟赛

    题目链接 T1 维护一个单调栈 #include <iostream> #include <cstdio> #define N 500000 #define rep(a,b,c ...

  8. 2017.10.2 QBXT 模拟赛

    题目链接 T1 我们所要求得是(a*b)|x 也就是 使(a*b)的倍数小于x的个数之和 1<=x<=n 我们可以 找一个c使得 (a*b*c)<=x 由于我们所求的是一个三元有序对 ...

  9. 2017.10.1 QBXT 模拟赛

    题目链接 T1 枚举右端点,前缀和优化.对于当前点x,答案为 sum[x][r]-sum[x][l-1]-(sum[z][r]-sum[z][l-1]) 整理为 sum[x][r]-sum[z][r] ...

随机推荐

  1. WPF 精修篇 属性触发器

    原文:WPF 精修篇 属性触发器 属性触发器是通过  某个条件触发改变属性 通过无代码实现功能 <Style TargetType="{x:Type Label}"> ...

  2. Codeforces Round #602 (Div. 2, based on Technocup 2020 Elimination Round 3) D2. Optimal Subsequences (Hard Version) 数据结构 贪心

    D2. Optimal Subsequences (Hard Version) This is the harder version of the problem. In this version, ...

  3. js SetTimeout传参问题

    今天写代码遇到这样一个问题,先上代码 <!--JS方法--> function textout(obj){ if(opac==60){opac=0;return;}; opac+=10; ...

  4. The trap of Bash trap

    Can you spot the problem with the following Bash script? resource_created="false" function ...

  5. autojump--懒人利器

    只有打开过的目录 autojump 才会记录,所以使用时间越长,autojump 才会越智能. 可以使用 autojump 命令,或者使用短命令 j. 跳转到指定目录 j directoryName ...

  6. vue的基础概念和语法01

    vue的特点和web开发中的常见高级功能 解耦视图和数据 可复用的组件 前端路由技术 状态管理 虚拟DOM 数据响应式 不是所有元素操作都Vue都会监听并实现数据响应式 //push方法:追加 thi ...

  7. IT兄弟连 Java语法教程 流程控制语句 循环结构语句4

    do-while循环 Java还有一种循环是do-while.与for.while这些在循环顶部判断条件表达式的语句不同,do-while是在循环底部进行条件表达式的检查.这意味着do-while循环 ...

  8. postman测试文件上传接口教程

    postman是一个很好的接口测试软件,有时候接口是Get请求方式的,肯定在浏览器都可以测了,不过对于比较规范的RestFul接口,限定了只能post请求的,那你只能通过工具来测了,浏览器只能支持ge ...

  9. Linux 下编写一个 PHP 扩展

        假设需求 开发一个叫做 helloWord 的扩展. 扩展里有一个函数,helloWord(). echo helloWord('Tom'); //返回:Hello World: Tom 本地 ...

  10. keras对图像数据进行增强 | keras data augmentation

    本文首发于个人博客https://kezunlin.me/post/8db507ff/,欢迎阅读最新内容! keras data augmentation Guide code # import th ...