2018 计蒜之道 初赛 第三场

A. 贝壳找房性价比

题解:按s排序后,斜率最大的点必定在相邻的两点之间。

#pragma warning(disable:4996)
#include<queue>
#include<map>
#include<string>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define ll long long
#define mem(arr,in) memset(arr,in,sizeof(arr))
using namespace std;
typedef pair<int, int> P;

const int maxn = 1e5 + 5;
const int INF = 1e9 + 7;

int T, n;
int va[maxn];

double get(P a, P b) {
    double k1 = (a.first == b.first) ? 1e15 : 1.0*abs(a.second - b.second) / abs(a.first - b.first);
    return k1;
}

int main()
{
    cin >> T;
    while (T--) {
        cin >> n;
        P p[maxn];
        for (int i = 1; i <= n; i++) {
            int u, v;
            scanf("%d%d", &u, &v);
            p[i] = P(u, v);

        }
        sort(p + 1, p + n + 1);

        double ans = 0;
        for (int i = 1; i < n; i++) ans = max(ans, get(p[i], p[i + 1]));

        if (ans == 1e15) printf("-1\n");
        else printf("%lf\n", ans);
    }
    return 0;
}

B. 贝壳找房户外拓展(简单)

题解:小数据,模拟就好了。当数据比较大的时候据说是用线段树维护一个矩阵,不会这操作。

#pragma warning(disable:4996)
#include<queue>
#include<map>
#include<string>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define ll long long
#define mem(arr,in) memset(arr,in,sizeof(arr))
using namespace std;
typedef pair<int, int> P;

const int maxn = 1004;
const int mod = 323232323;

int n, m, Q;
int state[maxn][maxn], we[maxn];

int main()
{
    while (scanf("%d %d %d", &n, &m, &Q) != EOF) {

        int cnt = 0;
        char op[2];
        P ca[maxn], de[maxn];

        while (Q--) {
            scanf("%s", op);
            if (op[0] == ‘I‘) {
                ++cnt;
                int l, r, y, pp, qq;
                cin >> l >> r >> y >> pp >> qq;

                l = min(l, r);
                r = max(l, r);

                we[cnt] = y;
                de[cnt] = P(l, r);

                ca[y] = P(pp, qq);
                for (int i = l; i <= r; i++) state[i][y] = cnt;
            }
            else if (op[0] == ‘Q‘) {
                int x, l, r;
                cin >> x >> l >> r;
                l = min(l, r);
                r = max(l, r);

                ll sum = 0;
                for (int j = l; j <= r; j++) {
                    if (state[x][j]) {
                        int yy = we[state[x][j]];
                        sum = ((ll)ca[yy].first*sum + (ll)ca[yy].second) % mod;
                    }
                }
                cout << sum << endl;
            }
            else {
                int ma;
                cin >> ma;
                int l = de[ma].first, r = de[ma].second;
                for (int i = l; i <= r; i++) {
                    state[i][we[ma]] = 0;
                }
                we[ma] = 0;
            }
        }
    }
    return 0;
}

C,D待补。。。

原文地址:https://www.cnblogs.com/zgglj-com/p/9061415.html

时间: 2024-08-27 14:54:10

2018 计蒜之道 初赛 第三场的相关文章

2018 计蒜之道 初赛 第五场

这次的比赛没有现场打,而是等到了今天才来补. 主要是因为那时候和HHHOJ上的比赛冲突了,所以就没写. 这次前三题的难度都比较低,但是就是一个T4要莫比乌斯反演.又是不可食用的. 好了我们开始看题. A. 贝壳找房搬家 这道题刚开始看的时候没看懂题意,觉得T1就是这种立体几何的题目,有种想死的感觉. 因为我认为这个方块可以不规则地想怎么放就怎么放的,其实题目中有一句话: 我们可以把这堆箱子看成一个\(x \times y \times z\) 的长方体. 什么?刚开始只能是长方体吗?好吧好像还是

计蒜之道 初赛 第三场 题解

腾讯手机地图 腾讯手机地图的定位功能用到了用户手机的多种信号,这其中有的信号的作用范围近,有的信号作用的范围则远一些.有的信号相对于用户在不同的方位强度是不同的,有的则是在任何一个方向上信号强度都一致的. 已知用户面向北方拿着自己的手机,在不同方位的各种信号覆盖区域可以被抽象成以用户为圆心的一系列扇形.已知每个扇形的半径 r,和每个扇形的两条边相对于正东方向的夹角度数.每个信号覆盖区域抽象出的扇形都可以通过从第一条边逆时针旋转到第二条边画出. <img src="http://res.ji

计蒜之道 初赛 第三场--腾讯手机地图

题目大意是: 在坐标系里给你n个扇形的半径.起始,结束度数,计算扇形覆盖的面积. 如图: (因为现在无法提交了,所以无法验证代码,若有错的地方请指正) 这题首先要做的是对边的度数排序,不过是对所有度数排序,最开始想的时候只对扇形开始边的那个度数排序,写了半天一堆if else,后来突然想到了用所有边的度数排序. 首先需要对输进去每每条边度数进行处理,我用的是这个结构体 struct DU { int du;//度数 int r;//当前度数所对应的半径 bool if_end;//是否为扇形的结

2017 计蒜之道 初赛 第三场 D. 腾讯狼人杀 (点边都带权的最大密度子图)

点边都带权的最大密度子图,且会有必须选的点. 写到一半没保存实验室断电,气炸.明天补详细题解. #include<bits/stdc++.h> using namespace std; const double eps = 1e-7; const int INF = 0x3f3f3f3f; const int MAXN= 405;//点数的最大值 const int MAXM= 1e6 + 10;//边数的最大值 #define captype double struct Edge{ int

2018 计蒜之道 初赛 第一场

百度无人车 二分 #include <bits/stdc++.h> using namespace std; typedef long long LL; const int maxn = 2e4 + 10; LL a[maxn]; int main(){ int n; scanf("%d", &n); for(int i = 1; i <= n; ++i) scanf("%lld", a + i); LL p, s; scanf("

2018 计蒜之道 初赛 第二场

签到完看到C没什么人过就溜乐. A.淘宝的推荐系统 直接DP,时间复杂度$O(∑nd)$ #include <bits/stdc++.h> using namespace std; #define rep(i, a, b) for (int i(a); i <= (b); ++i) #define dec(i, a, b) for (int i(a); i >= (b); --i) #define MP make_pair #define fi first #define se s

2017 计蒜之道 初赛 第五场 UCloud 的安全秘钥(中等)

每个 UCloud 用户会构造一个由数字序列组成的秘钥,用于对服务器进行各种操作.作为一家安全可信的云计算平台,秘钥的安全性至关重要.因此,UCloud 每年会对用户的秘钥进行安全性评估,具体的评估方法如下: 首先,定义两个由数字序列组成的秘钥 aa 和 bb近似匹配(\approx≈) 的关系.aa 和 bb 近似匹配当且仅当同时满足以下两个条件: |a|=|b|∣a∣=∣b∣,即 aa 串和 bb 串长度相等. 对于每种数字 cc,cc 在 aa 中出现的次数等于cc 在 bb 中出现的次数

2017 计蒜之道 初赛 第五场 D. UCloud 的安全秘钥(困难)

小数据打表,大数据暴力. 导致超时的主要原因是$m$小的询问次数太多,可以把$m≤10$的答案直接暴力打表存起来,$m>10$的用$C$题的方法即可. #include <iostream> #include <cstdio> #include <cstring> #include <string> #include <algorithm> #include <vector> #include <queue> #in

2017 计蒜之道 初赛 第五场 B. UCloud 的安全秘钥(简单)

暴力. 暴力枚举$S$串的每一个长度为$m$的子串,排序判断即可. #include <iostream> #include <cstdio> #include <cstring> #include <string> #include <algorithm> #include <vector> #include <queue> #include <stack> #include <map> #inc