*注意:这套题目应版权方要求,不得公示题面。

  因为业务水平下滑太严重,去和高一考NOIP模拟,sad。。。

Problem A 妹子

题目大意

  给定两个矩形,问一个能否将一个矩形放在另一个矩形里面。

  先可以根据面积判断哪一个被放在里面,然后判断一下能不能直接放或者旋转90°放进去。

  如果不行的话,接着考虑旋转。我们考虑这样↓放置小矩形。

  连接$EG$,作$GI\perp AD$于点$I$,$FJ\perp AD$与点$D$,$GK\perp JF$于点$G$。

  考虑上下界$AB$和$CD$和左界$AD$的限制,暂时放开$BC$的限制,然后我们考虑最小化$GI$。

  因为$GI^{2} = GE^2 - IE^2$,$GE$是定值,所以最小化$IG$等价于最大化$IE$。

  易证四边形$JKGI$是矩形,所以$JI = KG$。易证$\angle FGK=\angle JFE=\angle DEH $。

  再由$EH = FG,\angle EDH = \angle FKG = 90^{\circ}$,可得$\triangle EDH \cong  \triangle GKF$。

  所以$JI = KG = ED$当$E$点向下移动的时候$DI$增大,$JI,ED$减小,所以当$DJ = AD$时,$IG$有最小值。

  为了满足IG最小,我们这样放置矩形↓

  设$AF = x, \frac{EF}{EH} = k, w_{1} = EF, w_{2} = AD$。

  因为$\left\{\begin{matrix}\angle AFE = \angle DEH\ \ \ \ \ \ \ \ \ \ \\\angle EAF = \angle EDH = 90^{\circ} \end{matrix}\right.$,所以$\triangle AFE \sim \triangle DEH$、

  所以$ED = \frac{x}{k}, AE = \sqrt{w_{1}^{2} - x^{2}}$,然后有$k \cdot w_{2} - x = k\sqrt{w_{1}^{2} - x^{2}}$。

  然后有:

$\left\{ \begin{matrix} k^{2} \cdot w_{2}^2 - 2x\cdot k\cdot w_{2} + x^2 = k^2w_{1}^{2} - k^2x^{2} \\ 0< x \leqslant w_{1}\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \\ k \cdot w_{2} - x > 0\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \end{matrix} \right.$

  解一下,判断是否满足$CD$限制就行了。1

Code

 #include <iostream>
 #include <cstdlib>
 #include <cstdio>
 #include <cmath>
 using namespace std;
 typedef bool boolean;

 int T;
 int w1, h1, w2, h2;
 double w;

 inline void init() {
     scanf("%d%d%d%d", &w1, &h1, &w2, &h2);
     if (w1 * h1 > w2 * h2) {
         swap(w1, w2);
         swap(h1, h2);
     }
 }

 boolean checkRoot(double x) {
      || x > w1)
         return false;
     double k = w1 * 1.0 / h1;
     double y = sqrt(w1 * w1 - x * x);
     return x + y / k <= h2;
 }

 boolean check() {
     double k = w1 * 1.0 / h1;
     ;
      * k * w2;
     double c = k * (w1 * w1 - w2 * w2);
      * a * c;
     )
         return false;
     double qd = sqrt(delta);
      * a), x2 = (-b + qd) / ( * a);
     return checkRoot(x1) || checkRoot(x2);
 }

 namespace old {

     boolean check() {
         if (w1 <= w2 && h1 <= h2)
             return true;
         if (w1 >= w2 && h1 >= h2)
             return true;
         return false;
     }

     inline boolean solve() {
         if (check()) {
             puts("Yes");
             return true;
         }

         swap(h1, w1);
         if (check()) {
             puts("Yes");
             return true;
         }

         swap(h1, w1);
         swap(h2, w2);
         if (check()) {
             puts("Yes");
             return true;
         }
         return false;
     }

 }

 inline void solve() {
     if (old::solve())
         return;
     if (check())
         puts("Yes");
     else {
         swap(h1, w1);
         if (check())
             puts("Yes");
         else
             puts("No");
     }
 }

 int main() {
     scanf("%d", &T);
     while (T--) {
         init();
         solve();
     }
     ;
 }

Problem A

Problem B 旅程

题目大意

  给定$n$个点的带权有向完全图。要求支持删除一条边以及询问两点之间的最短路。

  $1\leqslant n\leqslant 200, 1\leqslant m\leqslant 10^5$,删除操作不超过$200$次。

  没有插入,倒着做,变成加。

  然后考虑这条边带来的贡献,枚举一对点,用它来更新最短路。

  时间复杂度$O(n^3 + m)$

Code

 #include <iostream>
 #include <cstdlib>
 #include <cstring>
 #include <cstdio>
 using namespace std;
 typedef bool boolean;

 ;
 );

 typedef class Operation {
     public:
         int type;
         int x, y;
         int data;

         Operation() {    }
         Operation(int type, int x, int y):type(type), x(x), y(y) {    }
 }Operation;

 int n, m;
 int d[N][N];
 int f[N][N];
 Operation *os;

 inline void init() {
     scanf("%d%d", &n, &m);
     ; i <= n; i++)
         ; j <= n; j++)
             scanf("%d", d[i] + j);
     os = )];
     , op, x, y; i <= m; i++) {
         scanf("%d%d%d", &op, &x, &y);
         os[i] = Operation(op, x, y);
         ) {
             os[i].data = d[x][y];
             d[x][y] = inf;
         }
     }
 }

 inline void solve() {
     memcpy(f, d, sizeof(f));
     ; i <= n; i++)
         f[i][i] = ;
     ; k <= n; k++)
         ; i <= n; i++)
             if (i ^ k)
                 ; j <= n; j++)
                     if ((j ^ k) && (j ^ i))
                         f[i][j] = min(f[i][k] + f[k][j], f[i][j]);

     for (int i = m; i; i--) {
         int op = os[i].type, x = os[i].x, y = os[i].y;
         ) {
             int data = os[i].data;
             if (data != inf) {
                 ; u <= n; u++)
                     ; v <= n; v++)
                         if (u ^ v)
                             f[u][v] = min(f[u][x] + data + f[y][v], f[u][v]);
             }
         } else {
             if (f[x][y] == inf)
                 os[i].data = -;
             else
                 os[i].data = f[x][y];
         }
     }

     ; i <= m; i++)
         )
             printf("%d\n", os[i].data);
 }

 int main() {
 //    freopen("journey.in", "r", stdin);
 //    freopen("journey.out", "w", stdout);
     init();
     solve();
     ;
 }

Problem B

Problem C 老大

题目大意

  要求在树上找两个点,然后其他所有点到它们两个点的距离的最小值的最大值最小。

Solution 1 Binary search

  二分答案$mid$,从最后一个点向上跳$mid$个点作为第一个选定点,然后把它的势力范围内的点都删掉,然后对剩下的点做一次,再判断是否有点剩余。

  时间复杂度$O(n\log n)$

Solution 2 Dynamic programming

  考虑只选一个点的时候,答案是最长链长度除以二向上取整。(根据最长链定义然后用反证法)。

  选两个点就相当于每个点有个势力范围,分界边将树分成一个比较好看的子树,以及它的补。正反各一次求树上最长链dp就完了。

Code

 #include <algorithm>
 #include <iostream>
 #include <cstdlib>
 #include <cstdio>
 #include <vector>
 #include <ctime>
 using namespace std;
 typedef bool boolean;

 typedef class Data {
     public:
         int mxlen;
         int mxdep;

         Data():mxlen(), mxdep() {    };
         Data(int mxlen, int mxdep):mxlen(mxlen), mxdep(mxdep) {    }

         Data operator + (Data b) {
             Data rt;
             rt.mxlen = max(mxlen, max(b.mxlen, b.mxdep + mxdep));
             rt.mxdep = max(mxdep, b.mxdep);
             return rt;
         }

         Data trans() {
             );
         }
 }Data;

 ;
 vector<int> *g;
 vector<int> *ts;
 Data *fu, *fd;

 Data *top;
 Data *pool;

 Data* alloc(int size) {
     Data* rt = top;
     top = top + size;
     return rt;
 }

 inline void init() {
     scanf("%d", &n);
     fu = )];
     fd = )];
     pool = ) + ];
     g = )];
     ts = )];
     top = pool;
     , u, v; i < n; i++) {
         scanf("%d%d", &u, &v);
         g[u].push_back(v);
         g[v].push_back(u);
     }
 //    cerr << clock() << endl;
 }

 void dp1(int p, int fa) {
     Data& f = fu[p];
     ; i < (signed) g[p].size(); i++) {
         int e = g[p][i];
         if (e == fa)
             continue;
         ts[p].push_back(e);
         dp1(e, p);
         f = f + fu[e].trans();
     }
 }

 void dp2(int p) {
     Data f = fd[p].trans() + Data(, );
     )
         f = Data(, );
     int s = (signed) ts[p].size();
     Data* pred = alloc(s + );
     Data* sufd = alloc(s + );
     Data d(, );
     ; i < s; i++) {
         int e = ts[p][i];
         d = d + fu[e].trans();
         pred[i] = d;
     }
     d = Data(, );
     ; ~i; i--) {
         int e = ts[p][i];
         d = d + fu[e].trans();
         sufd[i] = d;
     }

     ; i < s; i++) {
         int e = ts[p][i];
         fd[e] = f;
         if (i)
             fd[e] = fd[e] + pred[i - ];
         )
             fd[e] = fd[e] + sufd[i + ];
         dp2(e);
     }
 }

 int ceil2(int x) {
     ) >> ;
 }

 inline void solve() {
     dp1(, );
     dp2();
     ; i <= n; i++)
         res = min(res, max(ceil2(fd[i].mxlen), ceil2(fu[i].mxlen)));
     )
         res = ;
     printf("%d\n", res);
 }

 int main() {
 //    freopen("ob.in", "r", stdin);
 //    freopen("ob.out", "w", stdout);
     init();
     solve();
     ;
 }

Problem C

2018.9.22 NOIP模拟赛的更多相关文章

  1. 2018.10.16 NOIP模拟赛解题报告

    心路历程 预计得分:\(100 + 100 + 20 = 220\) 实际得分:\(100 + 100 + 30 = 230\) 辣鸡模拟赛.. T1T2都是一眼题,T3考验卡常数还只有一档暴力分. ...

  2. 2018.08.22 NOIP模拟 string(模拟)

    string [描述] 给定两个字符串 s,t,其中 s 只包含小写字母以及*,t 只包含小写字母. 你可以进行任意多次操作,每次选择 s 中的一个*,将它修改为任意多个(可以是 0 个)它的前一个字 ...

  3. 2018.02.12 noip模拟赛T2

    二兵的赌注 Description游戏中,二兵要进入了一家奇怪的赌场.赌场中有n个庄家,每个庄家都可以猜大猜小,猜一次一元钱.每一次开彩前,你都可以到任意个庄家那里下赌注.如果开彩结果是大,你就可以得 ...

  4. 2018.9.25 NOIP模拟赛

    *注意:这套题目应版权方要求,不得公示题面. 从这里开始 Problem A XOR Problem B GCD Problem C SEG 表示十分怀疑出题人水平,C题数据和标程都是错的.有原题,差 ...

  5. EZ 2018 07 06 NOIP模拟赛

    又是慈溪那边给的题目,这次终于没有像上次那样尴尬了, T1拿到了较高的暴力分,T2没写炸,然后T3写了一个优雅的暴力就203pts,Rank3了. 听说其它学校的分数普遍100+,那我们学校还不是强到 ...

  6. 2018.08.22 NOIP模拟 shop(lower_bound+前缀和预处理)

    Shop 有 n 种物品,第 i 种物品的价格为 vi,每天最多购买 xi 个. 有 m 天,第 i 天你有 wi 的钱,你会不停购买能买得起的最贵的物品.你需要求出你每天会购买多少个物品. [输入格 ...

  7. 2018.08.22 NOIP模拟 or(线段树)

    or [描述] 构造一个长度为 n 的非负整数序列 x,满足 m 个条件,第 i 个条件为x[li] | x[li+1] | - | x[ri]=pi. [输入] 第一行两个整数 n,m.接下来 m ...

  8. 2018/3/20 noip模拟赛 5分

    T1 傻逼题,写了cmp没sort,5分. T2 树上差分,写了树剖线段树,超时,0分. T3 树归,0分. 我是个zz

  9. 2018/3/18 noip模拟赛 20分

    T1 dp,特别裸特别简单,我放弃了写了个dfs. T2 树归,特别裸特别简单,我不会写. T3 贪心二分不知道什么玩意儿反正不会写就对了. 我是个智障

随机推荐

  1. CoAP 协议解析说明(转)

    CoAP 协议全面分析 HTTP与COAP 请求与响应示例 HTTP请求(文本格式) POST https://getman.cn/echo HTTP/1.1 User-Agent: Fiddler ...

  2. iOS - 数组字典模型根据模型属性key排序

    方法一: NSArray *sortArray = [arrayM sortedArrayUsingComparator:^NSComparisonResult(id obj1, id obj2) { ...

  3. js中的 substr方法与substring方法 不同

    一个参数时: 二者同为  从 第参数个 开始截取,一直到str 末尾,并返回. 二个参数时: substr(a,b):  从第a个字符开始, 截取b个. substring(a,b):  从第a个字符 ...

  4. canvas霓虹雨

    在codepen上看到一个Canvas做的下雨效果动画,感觉蛮有意思的.就研究了下,这里来分享下,实现技巧.效果可以见下面的链接. 霓虹雨: http://codepen.io/natewiley/f ...

  5. html5与css 1. web标准及组成

    学习目标 1.本专业介绍.HTML相关概念,HTML发展历史 2.WEB标准,W3C/WHATWG/ECMA相关概念 3.相关软件的应用以及站点的创建 4.HTML基本结构和HTML语法 5.HTML ...

  6. Jupyter notebook安装

    之前就装了jupyter notebook,但今天打开来发现是python2,并且似乎没法转换到python3??? so,再把python3的版本安装一下 打开CMD pip install jup ...

  7. vue2.0 源码解读(一)

    又看完一遍中文社区的教程接下来开始做vue2.0的源码解读了! 注:解读源码时一定要配合vue2.0的生命周期和API文档一起看 vue2.0的生命周期分为4主要个过程 create. 创建---实例 ...

  8. Codeforces 1132 - A/B/C/D/E/F - (Undone)

    链接:http://codeforces.com/contest/1132 A - Regular Bracket Sequence - [水] 题解:首先 "()" 这个的数量多 ...

  9. apache tomcat (catalina)查版本(solaris/unix)

    先进到tomcat的bin目录下(cd /tomcat目录/bin),在执行./version.sh https://blog.csdn.net/vv___/article/details/78653 ...

  10. c++stack容器介绍

    c++stack(堆栈)是一个容器的改编,它实现了一个先进后出的数据结构(FILO) 使用该容器时需要包含#include<stack>头文件: 定义stack对象的示例代码如下: sta ...