zoukankan      html  css  js  c++  java
  • 第一周 7.19-7.25

    暑假仍按周写。多校题每场另开一篇。

    7.19

     补一个计算客。

    429 企鹅手机地图

    由于角度都是整数。计算每个角度为1°的小扇形面积和即可。

    坑点在于r有1e5。精度要1e-3。所以pi精度要高。

    角度a=b的时候就是没有覆盖。理解成覆盖一周所以一直WA。

     1 # include <iostream>
     2 # include <cstdio>
     3 # include <cstring>
     4 # include <algorithm>
     5 using namespace std;
     6 const long double pi=3.141592653589793;
     7 long double MAX[360];
     8 
     9 int main(void)
    10 {
    11     int T; cin>>T;
    12     while(T--)
    13     {
    14         memset(MAX,0,sizeof(MAX));
    15         int n; scanf("%d",&n);
    16         while(n--)
    17         {
    18             int a,b; long double r;
    19             scanf("%Lf%d%d",&r,&a,&b);
    20             a+=90; b+=90;
    21             for(int i=a;i<b;i++) MAX[i]=max(MAX[i],r);
    22         }
    23         long double ans=0;
    24         for(int i=0;i<360;i++) ans+=pi*MAX[i]*MAX[i]/360;
    25         printf("%Lf
    ",ans);
    26     }
    27     return 0;
    28 }
    Aguin

    7.20

    补一个BC。

    HDU 5285 wyh2000 and pupil

    二分图。用染色法贪心的求最大即可。

     1 # include <iostream>
     2 # include <cstdio>
     3 # include <cstring>
     4 # include <vector>
     5 # include <algorithm>
     6 # include <queue>
     7 using namespace std;
     8 # define maxn 100010
     9 vector <int> vec[maxn];
    10 queue <int> q;
    11 int color[maxn];
    12 
    13 int main(void)
    14 {
    15     int T; cin>>T;
    16     while(T--)
    17     {
    18         memset(color,0,sizeof(color));
    19         int n,m; scanf("%d%d",&n,&m);
    20         for(int i=1;i<=n;i++) vec[i].clear();
    21         while(m--)
    22         {
    23             int x,y; scanf("%d%d",&x,&y);
    24             vec[x].push_back(y);
    25             vec[y].push_back(x);
    26         }
    27         if(n<=1) {printf("Poor wyh
    "); continue;}
    28         int ans=0,ok=1;
    29         for(int i=1;i<=n;i++)
    30         {
    31             if(!color[i])
    32             {
    33                 int black=1,white=0;
    34                 color[i]=1;
    35                 q.push(i);
    36                 while(!q.empty())
    37                 {
    38                     int tem=q.front(); q.pop();
    39                     for(int j=0;j<vec[tem].size();j++)
    40                     {
    41                         if(color[vec[tem][j]])
    42                         {
    43                             if(color[vec[tem][j]]==color[tem]) {ok=0; break;}
    44                         }
    45                         else
    46                         {
    47                             color[vec[tem][j]]=3-color[tem];
    48                             if(color[vec[tem][j]]==1) black++;
    49                             else white++;
    50                             q.push(vec[tem][j]);
    51                         }
    52                     }
    53                 }
    54                 ans+=max(black,white);
    55             }
    56         }
    57         if(!ok) printf("Poor wyh
    ");
    58         else
    59         {
    60             if(ans==n) printf("%d 1
    ",ans-1);
    61             else printf("%d %d
    ",ans,n-ans);
    62         }
    63     }
    64     return 0;
    65 }
    Aguin

    7.21

    打多校。

    2015 Multi-University Training Contest 1

    7.22

    补多校。

    打了个CF。

    7.23

    我打了多校?不我只是看了几个小时的题。

     2015 Multi-University Training Contest 2

    先补CF。

     D - Equivalent Strings

    ((其实这次CF很水

    按题目说的递归judge就可以了。比赛的时候浪费太久。没写完。

     1 # include <iostream>
     2 # include <cstdio>
     3 # include <cstring>
     4 using namespace std;
     5 char a[200005],b[200005];
     6 
     7 bool judge(int l1,int r1,int l2,int r2)
     8 {
     9     if((r1-l1+1)%2)
    10     {
    11         for(int i=0;i<=r1-l1;i++) if(a[l1+i]!=b[l2+i]) return false;
    12         return true;
    13     }
    14     if( judge(l1,(l1+r1)/2,l2,(l2+r2)/2) && judge((l1+r1)/2+1,r1,(l2+r2)/2+1,r2)) return true;
    15     if( judge(l1,(l1+r1)/2,(l2+r2)/2+1,r2) && judge((l1+r1)/2+1,r1,l2,(l2+r2)/2)) return true;
    16     return false;
    17 }
    18 
    19 int main(void)
    20 {
    21     scanf("%s %s",a+1,b+1);
    22     int len=strlen(a+1);
    23     if(judge(1,len,1,len)) printf("YES
    ");
    24     else printf("NO
    ");
    25     return 0;
    26 }
    Aguin

    7.24

    补多校。

    7.25

     补多校。

    晚上打了BC。

  • 相关阅读:
    PyQt5 -1 最基本的小窗口
    浅谈线段树
    最小生成树问题
    最短路问题
    多重背包问题
    02背包(嘻嘻,完全背包)
    01背包例题
    背包问题(好奇怪)
    关于深搜及广搜
    搜索回溯(第二)
  • 原文地址:https://www.cnblogs.com/Aguin/p/4658492.html
Copyright © 2011-2022 走看看