2019省赛训练组队赛3.31周四-17fj
https://vjudge.net/contest/289558#overview
A - Frog
Therearex frogs and y chicken in a garden. Kim found there are n heads and m legs in the garden. Please tell Kim how many frogs and chicken are there. (A frog has 4 legs, and a chicken has 2 legs.)
Input
First line contains an integer T (1 ≤ T ≤ 10), represents there are T test cases.
For each test case: Two number n and m.
1<=n, m <=100000. The data is legal.
Output
For each test case, output two numbers A and B – the number of frog and the number of chicken.
Sample Input
2
2 6
2 4
Sample Output
1 1
0 2
代码:
#include <stdio.h>
#include <iostream>
#include <math.h>
using namespace std; int T;
int N, M; int main() {
scanf("%d", &T);
while(T --) {
scanf("%d%d", &N, &M);
int x = M / - N;
int y = N - x;
printf("%d %d\n", x, y);
}
return ;
}
B - Triangles
This is a simple problem. Given two triangles A and B, you should determine they are intersect, contain or disjoint. (Public edge or point are treated as intersect.)
Input
First line contains an integer T (1 ≤ T ≤ 10), represents there are T test cases.
For each test case: X1 Y1 X2 Y2 X3 Y3 X4 Y4 X5 Y5 X6 Y6. All the coordinate are integer. (X1,Y1) , (X2,Y2), (X3,Y3) forms triangles A ; (X4,Y4) , (X5,Y5), (X6,Y6) forms triangles B.
-10000<=All the coordinate <=10000
Output
For each test case, output “intersect”, “contain” or “disjoint”.
Sample Input
2
0 0 0 1 1 0 10 10 9 9 9 10
0 0 1 1 1 0 0 0 1 1 0 1
Sample Output
disjoint
intersect
代码(模板题??? 比赛的时候 wa 到怀疑人生):
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std; const double eps=1e-;
const double pi=acos(-1.0);
int sgn(double x)
{
if (fabs(x)<eps) return ;
if (x<) return -;
return ;
}
struct Point
{
double x,y;
Point() {}
Point(double _x,double _y)
{
x=_x;
y=_y;
}
Point operator +(const Point &b) const
{
return Point(x+b.x,y+b.x);
}
Point operator -(const Point &b) const
{
// return Point(x-b.x,y-b.x);
return Point(x-b.x,y-b.y);
}
double operator ^(const Point &b) const
{
return x*b.y-y*b.x;
}
double operator *(const Point &b) const
{
return x*b.x+y*b.y;
}
Point operator /(const double b) const
{
return Point(x/b,y/b);
}
}; struct Line
{
Point s,e;
Line() {}
Line(Point _s,Point _e)
{
s=_s;
e=_e;
}
}; double dist(Point a,Point b)
{
return sqrt((a-b)*(a-b));
}
bool inter(Line l1,Line l2)
{
return
max(l1.s.x,l1.e.x)>=min(l2.s.x,l2.e.x) &&
max(l2.s.x,l2.e.x)>=min(l1.s.x,l1.e.x) &&
max(l1.s.y,l1.e.y)>=min(l2.s.y,l2.e.y) &&
max(l2.s.y,l2.e.y)>=min(l1.s.y,l1.e.y) &&
sgn((l2.s-l1.e)^(l1.s-l1.e))*sgn((l2.e-l1.e)^(l1.s-l1.e))<= &&
sgn((l1.s-l2.e)^(l2.s-l2.e))*sgn((l1.e-l2.e)^(l2.s-l2.e))<=;
}
Point o;
bool _cmp(Point p1,Point p2)
{
double tmp=(p1-o)^(p2-o);
if (sgn(tmp)>) return true;
else if (sgn(tmp)== && sgn(dist(p1,o)-dist(p2,o))<=) return true;
else return false;
} bool OnSeg(Point P,Line L)
{
return
sgn((L.s-P)^(L.e-P))== &&
sgn((P.x-L.s.x)*(P.x-L.e.x))<= &&
sgn((P.y-L.s.y)*(P.y-L.e.y))<=;
}
int inConvexPoly(Point a,Point p[],int n)
{
for (int i=;i<n;i++)
{
if (sgn((p[i]-a)^(p[(i+)%n]-a))<) return -; // out
else if (OnSeg(a,Line(p[i],p[(i+)%n]))) return ; // on
}
return ; // in
} Point p[]; int main()
{
int t;
scanf("%d",&t);
while (t--)
{
for (int i=;i<;i++) scanf("%lf%lf",&p[i].x,&p[i].y);
bool xj=false;
for (int i=;i<;i++)
{
for (int j=;j<;j++)
{
Line l1=Line(p[i],p[(i+)%]);
Line l2=Line(p[j+],p[(j+)%+]);
if (inter(l1,l2))
{
xj=true;
break;
}
}
if (xj) break;
}
if (xj)
{
printf("intersect\n");
continue;
}
int in1=,in2=;
o=(p[]+p[]+p[])/3.0;
sort(p,p+,_cmp);
o=(p[]+p[]+p[])/3.0;
sort(p+,p+,_cmp);
for (int i=;i<;i++)
{
if (inConvexPoly(p[i],p+,)==) in1++;
if (inConvexPoly(p[i+],p,)==) in2++;
}
if (in1==||in2==) printf("contain\n");
else printf("disjoint\n");
}
return ;
}
D - Game
Alice and Bob is playing a game.
Each of them has a number. Alice’s number is A, and Bob’s number is B.
Each turn, one player can do one of the following actions on his own number:
1. Flip: Flip the number. Suppose X = 123456 and after flip, X = 654321
2. Divide. X = X/10. Attention all the numbers are integer. For example X=123456 , after this action X become 12345(but not 12345.6). 0/0=0.
Alice and Bob moves in turn, Alice moves first. Alice can only modify A, Bob can only modify B. If A=B after any player’s action, then Alice win. Otherwise the game keep going on!
Alice wants to win the game, but Bob will try his best to stop Alice.
Suppose Alice and Bob are clever enough, now Alice wants to know whether she can win the game in limited step or the game will never end.
Input
First line contains an integer T (1 ≤ T ≤ 10), represents there are T test cases.
For each test case: Two number A and B. 0<=A,B<=10^100000.
Output
For each test case, if Alice can win the game, output “Alice”. Otherwise output “Bob”.
Sample Input
4
11111 1
1 11111
12345 54321
123 123
Sample Output
Alice
Bob
Alice
Alice
Hint
For the third sample, Alice flip his number and win the game.
For the last sample, A=B, so Alice win the game immediately even nobody take a move.
代码:
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring> using namespace std;
const int maxn = 1e5 + ; int Next[maxn]; void getNext(char x[], int m, int next[]) {
int i, j;
j = next[] = -;
i = ;
while(i < m) {
while(- != j && x[i] != x[j])
j = next[j];
next[++ i] = ++ j;
}
} int KMP_Count(char x[], int m, char y[], int n)
{
int i, j;
int ans = ;
getNext(x, m, Next);
i = j = ;
while(i < n) {
while(- != j && y[i] != x[j])
j = Next[j];
i ++;
j ++;
if(j >= m) {
ans ++;
j = Next[j];
}
}
return ans;
} int main() {
char x[maxn];
char y[maxn];
char p[maxn];
int T;
scanf("%d", &T);
while(T --) { scanf("%s%s", x, y); int lx = strlen(x);
int ly = strlen(y);
if(y[] == '' && ly == ) {
printf("Alice\n");
continue;
}
if(ly > lx) printf("Bob\n");
else {
if(KMP_Count(y, ly, x, lx)) {
printf("Alice\n");
continue;
} for(int i = ; i < ly / ; i ++)
swap(y[i], y[ly - i - ]); if(KMP_Count(y, ly, x, lx)) {
printf("Alice\n");
continue;
}
printf("Bob\n"); }
}
return ;
}
人生第一个 KMP 模板题吧算是
2019省赛训练组队赛3.31周四-17fj的更多相关文章
- 2019省赛训练组队赛3.26周二---FJUT 2016
A.Minimum’s Revenge There is a graph of n vertices which are indexed from 1 to n. For any pair of di ...
- hdu6578 2019湖南省赛D题Modulo Nine 经典dp
目录 题目 解析 AC_Code @ 题目 第一题题意是一共有{0,1,2,3}四种数字供选择,问有多少个长度为n的序列满足所有m个条件,每个条件是说区间[L,R]内必须有恰好x个不同的数字. 第二题 ...
- 2019牛客训练赛第七场 C Governing sand 权值线段树+贪心
Governing sand 题意 森林里有m种树木,每种树木有一定高度,并且砍掉他要消耗一定的代价,问消耗最少多少代价可以使得森林中最高的树木大于所有树的一半 分析 复杂度分析:n 1e5种树木,并 ...
- QFNU-ACM 2019.5.23组队赛 2019山东省赛复现
A.Calandar 题意:一年12个月,一个月30天,5天一周,已知某天的年月日星期数,求所给年月日的星期数是多少 思路:直接进行计算,其实每个月每年都是等长度的就使得计算的时候忽略年月,可以直接进 ...
- X-NUCA 2017 web专题赛训练题 阳光总在风雨后和default wp
0X0.前言 X-NUCA 2017来了,想起2016 web专题赛,题目都打不开,希望这次主办方能够搞好点吧!还没开赛,依照惯例会有赛前指导,放一些训练题让CTFer们好感受一下题目. 题目有一大 ...
- acm省赛选拔组队赛经验谈
省赛组队赛已经进行5场了,过半了. 从曾经的不会组队到如今逐渐磨合,尽管每次都有遗憾,可是我认为我们一直在进步.有些失误是要记录下来下次不能再犯的! 经验: 1:上场開始一定要有人(英语能力和算法综合 ...
- 2019新生赛 %%%xxh
笔记.md ...
- Contest - 2014 SWJTU ACM 手速测试赛(2014.10.31)
题目列表: 2146 Problem A [手速]阔绰的Dim 2147 Problem B [手速]颓废的Dim 2148 Problem C [手速]我的滑板鞋 2149 Problem D [手 ...
- PTA天梯赛训练题L1-064:估值一亿的AI核心代码(字符串模拟)
Update:smz说regex秒过Orz,yzd记在这里了. 听说今年天梯赛有个烦人的模拟,我便被队友逼着试做一下……一发15,二发20.记一记,要不然枉费我写这么久…… 自己还是代码能力太菜了,校 ...
随机推荐
- docker容器持久化卷讲解
docker容器自身存储数据效率比较低,因此我们为了提高磁盘IO的性能等,需要在容器中挂载一个外部存储设备.关于讲解大致如下: Docker中的数据可以存储在类似于虚拟机磁盘的介质中,在Docker中 ...
- Vue学习之路5-v-model指令
1. 指令释义 v-model在表单控件或者组件上创建双向绑定,本质上是负责监听用户的输入事件(onchange,onkeyup,onkeydown等,具体是哪个,还请查阅官方底层实现文档)以更新数据 ...
- C3P0连接池温习1
一.应用程序直接获取数据库连接的缺点 用户每次请求都需要向数据库获得链接,而数据库创建连接通常需要消耗相对较大的资源,创建时间也较长.假设网站一天10万访问量,数据库服务器就需要创建10万次连接,极大 ...
- spark on yarn模式:yarn命令杀除当前的application
在hadoop/bin目录下有yarn命令 yarn application -kill <applicationId>
- B - 畅通工程再续 最小生成树
相信大家都听说一个“百岛湖”的地方吧,百岛湖的居民生活在不同的小岛中,当他们想去其他的小岛时都要通过划小船来实现.现在政府决定大力发展百岛湖,发展首先要解决的问题当然是交通问题,政府决定实现百岛湖的全 ...
- PHP消息队列的实现方式与详解,值得一看
队列原理: 也是解耦的原理:业务系统和队列处理系统没有关系 一个写(业务系统),一个读(队列管理系统). 写的只管往队列里写,别的不用操心,读的能不能读完和写的也没有关系 同样,读的只管从队列里往外读 ...
- python flask里 post请求,JSON数据获取方式总结
#!flask/bin/python #encodig=utf-8 # _*_ coding:utf-8 _*_ # Writer : byz # dateTime : 2016-08-05 from ...
- Python框架学习之Flask中的Jinja2模板
前面也提到过在Flask中最核心的两个组件是Werkzeug和Jinja2模板.其中Werkzeug在前一节已经详细说明了.现在这一节主要是来谈谈Jinja2模板. 一.为什么需要引入模板: 在进行软 ...
- OpenCV3编程入门笔记(一)
---恢复内容开始--- 图像处理技术一般包括图像压缩,增强和复原,匹配.描述和识别3个部分.图像处理和计算机视觉的区别在于:图像处理侧重于“处理”图像——如增强.还原.去噪.分割等:而计算机视觉重点 ...
- Feature Extractor[inception v2 v3]
0 - 背景 在经过了inception v1的基础上,google的人员还是觉得有维度约间的空间,在<Rethinking the Inception Architecture for Com ...