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

  因为业务水平下滑太严重,去和高一考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. mock---前端搭建模拟服务

    在做前端开发接口的时候,往往接口都是从后端来的,这让前端很苦恼,但是有了 MockServer ,前端也可以搭建API服务了. server-mock是什么? 是一款nodejs的应用,用于搭建web ...

  2. 【Swing/文本组件】定义自动换行的文本域

    文本域组件:Swing中任何一个文本域(JTextArea)都是JTestArea类型的对象.常用的构造方法如下 public JTextArea() public JTextArea(String ...

  3. ubantu中怎样安装VMware Tools

    点击虚拟机选择安装VMware tools tar zxvf VMwareTools-9.6.0-1294478.tar.gz -C /root/(安装到的目录)cd /root/cd vmware- ...

  4. MUI学习01-顶部导航栏

    建议:先看一下MUI注意事项 连接:http://ask.dcloud.net.cn/article/122 固定栏靠前 所谓的固定栏,也就是带有.mui-bar属性的节点,都是基于fixed定位的元 ...

  5. TCP 套叠字

    一.  TCP 协议 # ------------TCP套叠字-------------------- server 端 import socket,time ip_port=('localhost' ...

  6. 黑盒测试实践——day01

    一.任务进展情况 小组成员讨论了测试案例的选取以及测试工具的选取,目前正在设计合理的测试方法,研究待测试系统的功能需求和缺陷. 二.存在的问题 测试工具的使用还是不很清楚. 三.解决方法 通过上网搜集 ...

  7. HTML调用PC摄像头【申明:来源于网络】

    HTML调用PC摄像头[申明:来源于网络] ---- 地址:http://www.oschina.net/code/snippet_2440934_55195 <!DOCTYPE html> ...

  8. 记录常用的adb命令

    1.启动adb服务 adb start-server 2.关闭服务 adb kill-server 3.进入shell环境 adb shell 4.安装应用 adb install -r xxx.ap ...

  9. opencart3如何安装模板

    opencart 3模板采用twig模式,安装模板也有点不大一样,随ytkah一起来看看opencart3如何安装模板吧1.下载模板文件,用ftp上传到对应的位置,一般有几个文件夹,比如:admin. ...

  10. (Detected problems with API compatibility(visit g.co/dev/appcompat for more info)

    在applicaiton里面加载这么一段代码: private void closeAndroidPDialog(){ try { Class aClass = Class.forName(" ...