[Updating] Tinkoff Challenge
来源:互联网 发布:腾讯数据分析 编辑:程序博客网 时间:2024/06/05 18:38
Problem A- Oleg and shares
判断
//Author: Lixiang#include<stdio.h>#include<algorithm>const int maxn=100001;struct A{ int a[maxn]; int Min,N,K; void init(){ Min=1000000000; scanf("%d%d",&N,&K); for(int i=1;i<=N;i++){ scanf("%d",&a[i]); Min=std::min(a[i],Min); } } void work(){ long long ans=0; int now=a[1]%K; for(int i=2;i<=N;i++) if(a[i]%K!=now){ puts("-1"); return; } for(int i=1;i<=N;i++) ans+=(a[i]-Min)/K; printf("%I64d\n",ans); }}sol;int main(){ sol.init(); sol.work(); return 0;}
Problem B - Igor and his way to work
判断是否能在最多两次转弯后到达目的地
BFS就行了
//Author: Lixiang#include<stdio.h>#include<queue>using namespace std;const int dx[]={0,0,1,-1};const int dy[]={1,-1,0,0};const int maxn=1001;struct Node{ short x,y; char s,last; Node make(int a,int b,int c,int la){ x=a;y=b;s=c;last=la; return *this; }}tmp;struct B{ queue <Node> Q; bool a[maxn][maxn],hash[maxn][maxn][5]; int N,M,sx,sy,ex,ey; char s[maxn]; void init(){ scanf("%d%d",&N,&M); for(int i=1;i<=N;i++){ scanf("%s",s+1); for(int j=1;j<=M;j++){ if(s[j]=='*')a[i][j]=0; else{ a[i][j]=1; if(s[j]=='S')sx=i,sy=j; if(s[j]=='T')ex=i,ey=j; } } } } bool check(int x,int y){ if(x>=1&&x<=N&&y>=1&&y<=M&&a[x][y]==1)return 1; else return 0; } void work(){ int x,y,turns,nx,ny,la; Q.push(tmp.make(sx,sy,0,-1)); //hash[sx][sy]=1; while(!Q.empty()){ x=Q.front().x;y=Q.front().y;turns=Q.front().s; la=Q.front().last; if(la!=-1)hash[x][y][la]=0; Q.pop(); for(int i=0;i<4;i++){ nx=x+dx[i];ny=y+dy[i]; if(!check(nx,ny))continue; if(hash[nx][ny][i])continue; if(nx==ex&&ny==ey){ puts("YES"); return ; } if(i==la){ Q.push(tmp.make(nx,ny,turns,i)); hash[nx][ny][i]=1; } else if(turns<=2){ if(turns==2&&nx!=ex&&ny!=ey)continue; Q.push(tmp.make(nx,ny,turns+1,i)); hash[nx][ny][i]=1; } } } puts("NO"); }}sol;int main(){ sol.init(); sol.work(); return 0;}
Problem C - Mice Problem
求出每个老鼠经过捕鼠器的时间段,找有没有重合的时间就行了
//Author: Lixiang#include<stdio.h>#include<algorithm>using namespace std;const int maxn=100001;const double eps=1e-11;double x1,y1,x2,y2,tmin,tmax;struct Mice{ double rx,ry,vx,vy; void init(){ scanf("%lf%lf%lf%lf",&rx,&ry,&vx,&vy); } void update(double a,double b,double v){ if(v==0){ if(a<0&&b>0)return; tmax=-1; } double p=a/v,q=b/v; if(p>q)swap(p,q); tmin=max(tmin,p); tmax=min(tmax,q); } void Update(){ update(x1-rx,x2-rx,vx); update(y1-ry,y2-ry,vy); }};struct C{ Mice mice[maxn]; int N; void init(){ tmin=0;tmax=1e100; scanf("%d%lf%lf%lf%lf",&N,&x1,&y1,&x2,&y2); for(int i=1;i<=N;i++){ mice[i].init(); mice[i].Update(); } } void work(){ if(tmin+eps>tmax)puts("-1"); else printf("%.20lf\n",tmin); }}sol;int main(){ sol.init(); sol.work(); return 0;}
0 0
- [Updating] Tinkoff Challenge
- Tinkoff Challenge
- Tinkoff Challenge
- Tinkoff Challenge
- [占坑]Tinkoff Challenge
- CF-Tinkoff Challenge-Elimination Round-A-Oleg and shares
- CF-Tinkoff Challenge-Elimination Round-C-Mice problem
- CF-Tinkoff Challenge-Elimination Round-D-Presents in Bankopolis
- [杂题 背包DP] Codeforces 793E Tinkoff Challenge
- [Segment tree Beats! || 分块] Codeforces 793F Tinkoff Challenge
- CF-Tinkoff Challenge-Elimination Round-B-Igor and his way to work
- [扫描线 二分图最大匹配 线段树优化网络流] Codeforces 793G Tinkoff Challenge
- csdnbloggers (updating)
- updating Inheritance
- Keep Updating
- updating homebrew
- REFERENCES (updating)
- New Challenge
- GCJ 2017 R2 题解(待续)
- ORACLE 常见等待事件
- CUDA-GPU programming Introduction (5)
- 常见的网站服务器架构有哪些?
- Unity 游戏用XLua的HotFix实现热更原理揭秘
- [Updating] Tinkoff Challenge
- 解析web.xml文件
- android基础(ANR)
- 信息安全工程师 学习笔记(二十)
- 在Express 使用session 做登录控制
- gcov获取程序频谱信息的步骤
- TensorFlow学习(二):变量常量类型
- 从源码角度分析RecyclerView监听滑动到底部失效
- 第一次练手。