开场连wa三发A题,差点心态崩了,还好坚持打完了,一共A了三题

A题,判断能不能放第一个圆,能放的话,先手比赢

  1. #include<map>
  2. #include<set>
  3. #include<cmath>
  4. #include<queue>
  5. #include<stack>
  6. #include<vector>
  7. #include<cstdio>
  8. #include<cassert>
  9. #include<iomanip>
  10. #include<cstdlib>
  11. #include<cstring>
  12. #include<iostream>
  13. #include<algorithm>
  14. #define pi acos(-1.0)
  15. #define ll long long
  16. #define mod 1000000007
  17. #define ls l,m,rt<<1
  18. #define rs m+1,r,rt<<1|1
  19. #pragma comment(linker, "/STACK:1024000000,1024000000")
  20.  
  21. using namespace std;
  22.  
  23. const double g=10.0,eps=1e-;
  24. const int N=+,maxn=+,inf=0x3f3f3f;
  25.  
  26. int main()
  27. {
  28. ios::sync_with_stdio(false);
  29. cin.tie();
  30. int a,b,r;
  31. cin>>a>>b>>r;
  32. if(a>=*r&&b>=*r)cout<<"First"<<endl;
  33. else cout<<"Second"<<endl;
  34. return ;
  35. }
  36. /*********************
  37.  
  38. *********************/

A

B题,数学题,模拟一下就好了,注意符号一定要在第一个位置,刚开始用gcd负号在第二个数那里了wa了一发

  1. #include<map>
  2. #include<set>
  3. #include<cmath>
  4. #include<queue>
  5. #include<stack>
  6. #include<vector>
  7. #include<cstdio>
  8. #include<cassert>
  9. #include<iomanip>
  10. #include<cstdlib>
  11. #include<cstring>
  12. #include<iostream>
  13. #include<algorithm>
  14. #define pi acos(-1.0)
  15. #define ll long long
  16. #define mod 1000000007
  17. #define ls l,m,rt<<1
  18. #define rs m+1,r,rt<<1|1
  19. #pragma comment(linker, "/STACK:1024000000,1024000000")
  20.  
  21. using namespace std;
  22.  
  23. const double g=10.0,eps=1e-;
  24. const int N=+,maxn=+,inf=0x3f3f3f;
  25.  
  26. int gcd(int a,int b)
  27. {
  28. return b ? gcd(b,a%b):a;
  29. }
  30. int main()
  31. {
  32. ios::sync_with_stdio(false);
  33. cin.tie();
  34. int n,m,a,b,a1,b1;
  35. cin>>n>>m;
  36. for(int i=;i<=n;i++)
  37. {
  38. cin>>a;
  39. if(i==)a1=a;
  40. }
  41. for(int i=;i<=m;i++)
  42. {
  43. cin>>b;
  44. if(i==)b1=b;
  45. }
  46. if(n>m)
  47. {
  48. if(a1*b1>)cout<<"Infinity"<<endl;
  49. else cout<<"-Infinity"<<endl;
  50. }
  51. else if(n<m)cout<<"0/1"<<endl;
  52. else
  53. {
  54. int x=gcd(a1,b1);
  55. a1/=x;b1/=x;
  56. if(a1*b1<)cout<<"-"<<abs(a1)<<"/"<<abs(b1)<<endl;
  57. else cout<<abs(a1)<<"/"<<abs(b1)<<endl;
  58. }
  59. return ;
  60. }
  61. /*********************
  62.  
  63. *********************/

B

C题才是最水的题。。。搞一个记录最大的数组从后往前扫一边就出来了

  1. #include<map>
  2. #include<set>
  3. #include<cmath>
  4. #include<queue>
  5. #include<stack>
  6. #include<vector>
  7. #include<cstdio>
  8. #include<cassert>
  9. #include<iomanip>
  10. #include<cstdlib>
  11. #include<cstring>
  12. #include<iostream>
  13. #include<algorithm>
  14. #define pi acos(-1.0)
  15. #define ll long long
  16. #define mod 1000000007
  17. #define ls l,m,rt<<1
  18. #define rs m+1,r,rt<<1|1
  19. #pragma comment(linker, "/STACK:1024000000,1024000000")
  20.  
  21. using namespace std;
  22.  
  23. const double g=10.0,eps=1e-;
  24. const int N=+,maxn=+,inf=0x3f3f3f;
  25.  
  26. int maxx[N];
  27. int main()
  28. {
  29. ios::sync_with_stdio(false);
  30. cin.tie();
  31. string s;
  32. cin>>s;
  33. maxx[s.size()]=;
  34. for(int i=s.size()-;i>=;i--)
  35. maxx[i]=max(maxx[i+],s[i]-'');
  36. string ans="";
  37. for(int i=;i<s.size();i++)
  38. {
  39. if(maxx[i]==s[i]-'')ans+=s[i];
  40. }
  41. cout<<ans<<endl;
  42. return ;
  43. }
  44. /*********************
  45.  
  46. *********************/

C

D题,dfs,如果一个点能从两个方向到达的话,那就输出yes,用一个数组记录到达的位置

  1. #include<map>
  2. #include<set>
  3. #include<cmath>
  4. #include<queue>
  5. #include<stack>
  6. #include<vector>
  7. #include<cstdio>
  8. #include<cassert>
  9. #include<iomanip>
  10. #include<cstdlib>
  11. #include<cstring>
  12. #include<iostream>
  13. #include<algorithm>
  14. #define pi acos(-1.0)
  15. #define ll long long
  16. #define mod 1000000007
  17. #define ls l,m,rt<<1
  18. #define rs m+1,r,rt<<1|1
  19. #pragma comment(linker, "/STACK:1024000000,1024000000")
  20.  
  21. using namespace std;
  22.  
  23. const double g=10.0,eps=1e-;
  24. const int N=+,maxn=+,inf=0x3f3f3f;
  25.  
  26. char ma[N][N];
  27. int dx[]= {,,-,};
  28. int dy[]= {,,,-};
  29. bool vis[N][N];
  30. int n,m,sx,sy;
  31. pair<int,int>v[N][N];
  32. bool ok(int x,int y)
  33. {
  34. if(ma[x][y]=='.'&&!vis[x][y])return ;
  35. return ;
  36. }
  37. void dfs(int x,int y)
  38. {
  39. int fx=x,fy=y;
  40. while(fx<)fx+=n;
  41. fx%=n;
  42. while(fy<)fy+=m;
  43. fy%=m;
  44. if(vis[fx][fy]&&(v[fx][fy].first!=x||v[fx][fy].second!=y))
  45. {
  46. cout<<"Yes"<<endl;
  47. exit();
  48. }
  49. if(!ok(fx,fy))return ;
  50. vis[fx][fy]=;
  51. v[fx][fy]=make_pair(x,y);
  52. for(int i=;i<;i++)
  53. dfs(x+dx[i],y+dy[i]);
  54. }
  55. int main()
  56. {
  57. ios::sync_with_stdio(false);
  58. cin.tie();
  59. cin>>n>>m;
  60. for(int i=;i<n;i++)
  61. {
  62. for(int j=;j<m;j++)
  63. {
  64. cin>>ma[i][j];
  65. if(ma[i][j]=='S')
  66. {
  67. sx=i;
  68. sy=j;
  69. ma[i][j]='.';
  70. }
  71. }
  72. }
  73. memset(vis,,sizeof vis);
  74. dfs(sx,sy);
  75. cout<<"No"<<endl;
  76. return ;
  77. }
  78. /*********************
  79. 5 5
  80. ##.##
  81. #..##
  82. ..###
  83. .#S..
  84. ##.##
  85. *********************/

D

E题,计算几何,极角排序,先dfs一遍预处理出每个节点有多少子节点,然后dfs一遍,每个区间进行极角排序(刚开始以为只需要一遍极角排序就行了,后来

  1. #include<map>
  2. #include<set>
  3. #include<cmath>
  4. #include<queue>
  5. #include<stack>
  6. #include<vector>
  7. #include<cstdio>
  8. #include<cassert>
  9. #include<iomanip>
  10. #include<cstdlib>
  11. #include<cstring>
  12. #include<iostream>
  13. #include<algorithm>
  14. #define pi acos(-1.0)
  15. #define ll long long
  16. #define mod 1000000007
  17. #define ls l,m,rt<<1
  18. #define rs m+1,r,rt<<1|1
  19. #pragma comment(linker, "/STACK:1024000000,1024000000")
  20.  
  21. using namespace std;
  22.  
  23. const double g=10.0,eps=1e-;
  24. const int N=+,maxn=+,inf=0x3f3f3f;
  25.  
  26. struct point {
  27. double x,y;
  28. int id;
  29. }p[N];
  30. point p0;
  31. vector<int>v[N];
  32. int sz[N],ans[N];
  33. bool comp(point p1,point p2)
  34. {
  35. double te=(p2.x-p0.x)*(p1.y-p0.y)-(p2.y-p0.y)*(p1.x-p0.x);
  36. if(te<)return ;
  37. return ;
  38. }
  39. void dfs(int u,int fa)
  40. {
  41. sz[u]=;
  42. for(int i=;i<v[u].size();i++)
  43. if(v[u][i]!=fa)
  44. {
  45. dfs(v[u][i],u);
  46. sz[u]+=sz[v[u][i]];
  47. }
  48. }
  49. void dfssort(int u,int fa,int be,int en)
  50. {
  51. for(int i=be;i<en;i++)
  52. if(p[i].x<p[be].x||(p[i].x==p[be].x&&p[i].y<p[be].y))
  53. swap(p[i],p[be]);
  54. p0=p[be];
  55. ans[p[be].id]=u;
  56. sort(p+be+,p+en,comp);
  57. int te=be;
  58. for(int i=; i<v[u].size(); i++)
  59. {
  60. if(v[u][i]!=fa)
  61. {
  62. dfssort(v[u][i],u,te+,te+sz[v[u][i]]+);
  63. te+=sz[v[u][i]];
  64. }
  65. }
  66. }
  67. int main()
  68. {
  69. ios::sync_with_stdio(false);
  70. cin.tie();
  71. int n;
  72. cin>>n;
  73. for(int i=;i<n;i++)
  74. {
  75. int a,b;
  76. cin>>a>>b;
  77. v[a].push_back(b);
  78. v[b].push_back(a);
  79. }
  80. for(int i=;i<n;i++)
  81. {
  82. cin>>p[i].x>>p[i].y;
  83. p[i].id=i+;
  84. }
  85. dfs(,-);
  86. // for(int i=1;i<=n;i++)cout<<sz[i]<<endl;
  87. dfssort(,-,,n);
  88. for(int i=;i<=n;i++)cout<<ans[i]<<" ";
  89. cout<<endl;
  90. return ;
  91. }
  92. /*********************
  93. 3
  94. 1 3
  95. 2 3
  96. 0 0
  97. 1 1
  98. 2 0
  99. *********************/

E

发现这样子节点可能会坐标倒回来,有可能相交)

CodeForces - 197D的更多相关文章

  1. Codeforces 197D - Infinite Maze

    197D - Infinite Maze 思路:bfs,如果一个点被搜到第二次,那么就是符合要求的. 用vis[i][j].x,vis[i][j].y表示i,j(i,j是取模过后的值)这个点第一次被搜 ...

  2. [CodeForces - 197D] D - Infinite Maze

    D - Infinite Maze We've got a rectangular n × m-cell maze. Each cell is either passable, or is a wal ...

  3. python爬虫学习(5) —— 扒一下codeforces题面

    上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...

  4. 【Codeforces 738D】Sea Battle(贪心)

    http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...

  5. 【Codeforces 738C】Road to Cinema

    http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...

  6. 【Codeforces 738A】Interview with Oleg

    http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interv ...

  7. CodeForces - 662A Gambling Nim

    http://codeforces.com/problemset/problem/662/A 题目大意: 给定n(n <= 500000)张卡片,每张卡片的两个面都写有数字,每个面都有0.5的概 ...

  8. CodeForces - 274B Zero Tree

    http://codeforces.com/problemset/problem/274/B 题目大意: 给定你一颗树,每个点上有权值. 现在你每次取出这颗树的一颗子树(即点集和边集均是原图的子集的连 ...

  9. CodeForces - 261B Maxim and Restaurant

    http://codeforces.com/problemset/problem/261/B 题目大意:给定n个数a1-an(n<=50,ai<=50),随机打乱后,记Si=a1+a2+a ...

随机推荐

  1. DKLang Translation Editor

    https://yktoo.com/en/software/dklang-traned Features Translation using a dictionary (so-called Trans ...

  2. MongoDB-4: 查询(二-数组、内嵌文档)

    一.简介 我们上一篇介绍了db.collection.find()可以实现根据条件查询和指定使用投影运算符返回的字段省略此参数返回匹配文档中的所有字段,我们今天介绍了对数组和内嵌文档的查询操作,尤其是 ...

  3. 设置EditText明文切换

    版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/mingyue_1128/article/details/37651793 if (!isChecke ...

  4. oracle ORA-01704: string literal too long

    导出数据时,在SQL拼接处,提示 oracle ORA-01704: string literal too long sql:  WITH already_in AS (SELECT distinct ...

  5. 浅谈WebService SOAP、Restful、HTTP(post/get)请求

    http://www.itnose.net/detail/6189456.html 浅谈WebService SOAP.Restful.HTTP(post/get)请求 2015-01-09 19:2 ...

  6. Java并发(1):synchronized

    虽然多线程编程极大地提高了效率,但是也会带来一定的隐患.比如说两个线程同时往一个数据库表中插入不重复的数据,就可能会导致数据库中插入了相同的数据.今天我们就来一起讨论下线程安全问题,以及Java中提供 ...

  7. CNN学习笔记:线性回归

    CNN学习笔记:Logistic回归 线性回归 二分类问题 Logistic回归是一个用于二分分类的算法,比如我们有一张图片,判断其是否为一张猫图,为猫输出1,否则输出0. 基本术语 进行机器学习,首 ...

  8. jsp验证正则表达式

    jsp验证正则表达式 下面都是我收集的一些比较常用的正则表达式,因为平常可能在表单验证的时候,用到的比较多.特发出来,让各位朋友共同使用.呵呵. 匹配中文字符的正则表达式: [u4e00-u9fa5] ...

  9. Java架构搜集

    1. 2.

  10. cart_购物车小程序

    #author:leon product_list= [ ('iphone',5800), ('mac pro',9800), ('bike',800), ('watch',6000), ('coff ...