2017 ACM/ICPC Asia Regional Qingdao Online
Apple
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)
Total Submission(s): 982 Accepted Submission(s): 323
In the first line of each case, there are eight integers x1,y1,x2,y2,x3,y3,x,y, as described above.
The absolute values of integers in input are less than or equal to 1,000,000,000,000.
It is guaranteed that, any three of the four positions do not lie on a straight line.
-2 0 0 -2 2 0 2 -2
-2 0 0 -2 2 0 0 2
-2 0 0 -2 2 0 1 1
Rejected
Rejected
圆的反演,java大数走一波
其实用外接圆半径及点那个不复杂的东西也可以玩
import java.io.*;
import java.util.*;
import java.math.*; public class Main
{
static public BigInteger xu[]=new BigInteger[4];
static public BigInteger xd[]=new BigInteger[4];
static public BigInteger yu[]=new BigInteger[4];
static public BigInteger yd[]=new BigInteger[4];
static public void main(String[] args)
{
Scanner cin=new Scanner(System.in);
int T=cin.nextInt();
while(T-->0)
{
for(int i=0;i<4;i++)
{
xu[i]=cin.nextBigInteger();
yu[i]=cin.nextBigInteger();
xd[i]=BigInteger.ONE;
yd[i]=BigInteger.ONE;
}
for(int i=1;i<4;i++)
{
xu[i]=xu[i].subtract(xu[0]);
yu[i]=yu[i].subtract(yu[0]);
}
for(int i=1;i<4;i++)
{
xd[i]=xu[i].multiply(xu[i]).add(yu[i].multiply(yu[i]));
yd[i]=xu[i].multiply(xu[i]).add(yu[i].multiply(yu[i]));
}
BigInteger t=xu[1].multiply(yu[2]).subtract(yd[1].multiply(xd[2]));
t=t.subtract(yu[1].multiply(xu[2]).subtract(xd[1].multiply(yd[2])));
if(t.compareTo(BigInteger.ZERO)<0)
{
t=xu[1];xu[1]=xu[2];xu[2]=t;
t=yu[1];yu[1]=yu[2];yu[2]=t;
t=xd[1];xd[1]=xd[2];xd[2]=t;
t=yd[1];yd[1]=yd[2];yd[2]=t;
}
for(int i=2;i<=3;i++)
{
xu[i]=xu[i].multiply(xd[1]).subtract(xu[1].multiply(xd[i]));
xd[i]=xd[i].multiply(xd[1]);
yu[i]=yu[i].multiply(yd[1]).subtract(yu[1].multiply(yd[i]));
yd[i]=yd[i].multiply(yd[1]);
}
t=xu[3].multiply(yu[2]).subtract(yd[3].multiply(xd[2]));
t=t.subtract(yu[3].multiply(xu[2]).subtract(xd[3].multiply(yd[2])));
if(t.compareTo(BigInteger.ZERO)>=0)System.out.println("Rejected");
else System.out.println("Accepted");
}
}
}
The Dominator of Strings
Time Limit: 3000/3000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)
Total Submission(s): 6778 Accepted Submission(s): 713
For each test case, the first line contains an integer N indicating the size of the set.
Each of the following N lines describes a string of the set in lowercase.
The total length of strings in each case has the limit of 100000.
The limit is 30MB for the input file.
#include<bits/stdc++.h> using namespace std;
const int MAXN = ;
int n,k;
int Paiming[MAXN+],tmp[MAXN+];
int flag;
bool comp_sa(int i, int j)
{
if(Paiming[i] != Paiming[j])
return Paiming[i] < Paiming[j];
else{
int ri = i+k <= n? Paiming[i+k] : -;
int rj = j+k <= n? Paiming[j+k] : -;
return ri < rj;
}
} void calc_sa(string &S, int *sa)
{
n = S.size();
for(int i = ; i <= n; i++)
{
sa[i] = i;
Paiming[i] = i < n ? S[i] : -;
} for( k =; k <= n; k *= )
{
sort(sa,sa+n+,comp_sa);
tmp[sa[]] = ;
for(int i = ; i <= n; i++)
{
tmp[sa[i]] = tmp[sa[i-]] + (comp_sa(sa[i-],sa[i]) ? : );
}
for(int i = ; i <= n; i++)
{
Paiming[i] = tmp[i];
}
}
} int SuffixArrayMatch(string &S, int *sa, string T)
{ int lhs = , rhs = S.size();
while(rhs - lhs > )
{
int mid = (lhs + rhs)>>;
if(S.compare(sa[mid],T.size(),T) < ) lhs = mid;
else rhs=mid;
}
return S.compare(sa[rhs],T.size(),T) == ;
}
int main()
{
int t;
ios::sync_with_stdio(false);
cin>>t;
string s[],longs;
while(t--){
int n,l=-,p=-,i;
cin>>n;
memset(Paiming,,sizeof Paiming);
memset(tmp,,sizeof tmp);
for(i=;i<n;i++){
cin>>s[i];
int len=s[i].size();
if(len>l){
l=len;
longs=s[i];
p=i;
}
}
if(n==){
cout<<longs<<endl;
continue;
}
int *sa = new int[longs.size()+];
calc_sa(longs,sa);
for(i=;i<n;i++){
if(p==i)continue;
if(!SuffixArrayMatch(longs,sa,s[i]))
break;
}
//delete [] sa;
sa = NULL;
if(i>=n){
cout<<longs<<endl;
}else {
cout<<"No"<<endl;
}
}
}
Chinese Zodiac
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)
Total Submission(s): 2451 Accepted Submission(s): 1645
Victoria is married to a younger man, but no one knows the real age difference between the couple. The good news is that she told us their Chinese Zodiac signs. Their years of birth in luner calendar is not the same. Here we can guess a very rough estimate of the minimum age difference between them.
If, for instance, the signs of Victoria and her husband are ox and rabbit respectively, the estimate should be 2 years. But if the signs of the couple is the same, the answer should be 12 years.
For each test case a line of two strings describes the signs of Victoria and her husband.
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
using namespace std;
int main()
{
char m[][]={
"rat", "ox", "tiger", "rabbit", "dragon", "snake", "horse", "sheep", "monkey", "rooster", "dog" , "pig"
};
int t,s;
scanf("%d",&t);
while(t--){
char p[],q[];
scanf("%s%s",&p,&q);
if(strcmp(p,q)==){
puts("");
}else {
int i,pp,qq;
for(i=;i<;i++){
if(strcmp(m[i],p)==){
pp=i;
}
if(strcmp(m[i],q)==){
qq=i;
}
}
s=(pp-qq);
if(s>){
s=s-;
}
printf("%d\n",-s);
}
}
}
Smallest Minimum Cut
Time Limit: 2000/2000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)
Total Submission(s): 3297 Accepted Submission(s): 602
Each case describes a network G, and the first line contains two integers n (2≤n≤200) and m (0≤m≤1000) indicating the sizes of nodes and edges. All nodes in the network are labelled from 1 to n.
The second line contains two different integers s and t (1≤s,t≤n) corresponding to the source and sink.
Each of the next m lines contains three integers u,v and w (1≤w≤255) describing a directed edge from node u to v with capacity w.
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MAXN 2333
#define MAXM 2333333
struct Edge
{
int v,next;
ll cap;
} edge[MAXM];
int head[MAXN],pre[MAXN],cur[MAXN],level[MAXN],gap[MAXN],NV,NE,n,m,vs,vt;
void ADD(int u,int v,ll cap,ll cc=)
{
edge[NE].v=v;
edge[NE].cap=cap;
edge[NE].next=head[u];
head[u]=NE++; edge[NE].v=u;
edge[NE].cap=cc;
edge[NE].next=head[v];
head[v]=NE++;
}
ll SAP(int vs,int vt)
{
memset(pre,-,sizeof(pre));
memset(level,,sizeof(level));
memset(gap,,sizeof(gap));
for(int i=; i<=NV; i++)cur[i]=head[i];
int u=pre[vs]=vs;
ll aug=-,maxflow=;
gap[]=NV;
while(level[vs]<NV)
{
loop:
for(int &i=cur[u]; i!=-; i=edge[i].next)
{
int v=edge[i].v;
if(edge[i].cap&&level[u]==level[v]+)
{
aug==-?aug=edge[i].cap:aug=min(aug,edge[i].cap);
pre[v]=u;
u=v;
if(v==vt)
{
maxflow+=aug;
for(u=pre[u]; v!=vs; v=u,u=pre[u])
{
edge[cur[u]].cap-=aug;
edge[cur[u]^].cap+=aug;
}
aug=-;
}
goto loop;
}
}
int minlevel=NV;
for(int i=head[u]; i!=-; i=edge[i].next)
{
int v=edge[i].v;
if(edge[i].cap&&minlevel>level[v])
{
cur[u]=i;
minlevel=level[v];
}
}
if(--gap[level[u]]==)break;
level[u]=minlevel+;
gap[level[u]]++;
u=pre[u];
}
return maxflow;
} int main()
{
int T,u,v,w;
scanf("%d",&T);
while(T--)
{
scanf("%d%d",&n,&m);
scanf("%d%d",&vs,&vt);
NV=n,NE=;
memset(head,-,sizeof(head));
for(int i=; i<=m; i++)
{
scanf("%d%d%d",&u,&v,&w);
ADD(u,v,(ll)w*MAXM+);
}
ll ans=SAP(vs,vt);
printf("%d\n",ans%MAXM);
}
return ;
}
A Cubic number and A Cubic Number
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)
Total Submission(s): 4947 Accepted Submission(s): 1346
For each test case, a line contains a prime number p (2≤p≤1012).
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
bool la(LL x)
{
LL l=,r=1e6+;
while(l<=r)
{
LL mi=(l+r)/;
LL y=mi-;
if(mi*mi+y*y+mi*y==x)
return ;
else if(mi*mi+y*y+mi*y<x)
l=mi+;
else r=mi-;
}
return ;
}
int main()
{
int T;
scanf("%d",&T);
while(T--)
{
LL n;
scanf("%lld",&n);
printf("%s\n",la(n)?"YES":"NO");
}
return ;
}
2017 ACM/ICPC Asia Regional Qingdao Online的更多相关文章
- HDU - 6215 2017 ACM/ICPC Asia Regional Qingdao Online J - Brute Force Sorting
Brute Force Sorting Time Limit: 1 Sec Memory Limit: 128 MB 题目连接 http://acm.hdu.edu.cn/showproblem.p ...
- 2017 ACM/ICPC Asia Regional Qingdao Online 记录
题目链接 Qingdao Problem C AC自动机还不会,暂时暴力水过. #include <bits/stdc++.h> using namespace std; #define ...
- 2017 ACM/ICPC Asia Regional Qingdao Online解题报告(部分)
HDU 6206 Apple 题意: 给出四个点的坐标(每个点的坐标值小于等于1,000,000,000,000),问最后一个点是否在前三个点组成的三角形的外接圆内,是输出Accept,否输出Reje ...
- 2017 ACM/ICPC Asia Regional Qingdao Online Solution
A : Apple 题意:给出三个点,以及另一个点,求最后一个点是否在三个点的外接圆里面,如果在或者在边界上,输出“Rejected”,否则输出"Accepted" 思路:先求一个 ...
- 2017 ACM/ICPC Asia Regional Qingdao Online - 1011 A Cubic number and A Cubic Number
2017-09-17 17:12:11 writer:pprp 找规律,质数只有是两个相邻的立方数的差才能形成,公式就是3 * n * (n + 1) +1, 判断读入的数是不是满足 这次依然只是做了 ...
- 2017 ACM/ICPC Asia Regional Qingdao Online - 1008 Chinese Zodiac
2017-09-17 13:28:04 writer:pprp 签到题:1008 Chinese Zodiac #include <iostream> #include <strin ...
- 2017 ACM/ICPC Asia Regional Qingdao Online 1003 The Dominator of Strings hdu 6208
The Dominator of Strings Time Limit: 3000/3000 MS (Java/Others) Memory Limit: 65535/32768 K (Java ...
- 2016 ACM/ICPC Asia Regional Qingdao Online 1001/HDU5878 打表二分
I Count Two Three Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others ...
- HDU 5889 Barricade 【BFS+最小割 网络流】(2016 ACM/ICPC Asia Regional Qingdao Online)
Barricade Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total S ...
随机推荐
- 终于 Vue.js 成为世界一流的框架
终于 Vue.js 成为世界一流的框架 随着美团开源基于 Vue.js 的微信小程序框架 mpvue, Vue.js 在微信小程序端的能力被补齐,于是 Vue.js 成为了一个唯一能在 Web, H5 ...
- 模拟一次CSRF(跨站请求伪造)例子,适合新手
GET请求伪造 有一个论坛网站,网站有一个可以关注用户的接口,但是必须登录的用户才可以关注其他用户. 这个网站的网站是www.a.com 有一天有一个程序员想提高自己的知名度,决定利用CSRF让大家关 ...
- mysqlsla安装和使用介绍
安装mysqlsla源码路径:https://github.com/daniel-nichter/hackmysql.com源码存放路径:/usr/local/src1.获取源码如果没有git命令,请 ...
- ubuntu 16.0 利用ant编译 hadoop-eclipse-plugins2.6.0
折腾了两天,抱着不放弃的精神,我终于编译出我自己所需的hadoop中在eclipse中的插件 在网上下载的可能因为版本不一致,在编译的时候出现各种各样的问题,包括你的eclipse版本和hadoop版 ...
- 使用JDK自带的工具jstack找出造成运行程序死锁的原因
Java多线程编程也是Java面试中经常考察的内容.刚接触Java多线程编程的朋友们,可能会不慎写出一些会导致死锁(deadlock)的应用出来.如何分析造成Java多线程的原因呢?很多时候我们在怀疑 ...
- config文件声明非系统节点的方法
有一些自定义节点如果不声明会报出无法识别的节点 XXX 这时候要声明该节点 写法如下 <configSections> <!--声明一个节点组--> <sectionGr ...
- POJ1077 八数码 BFS
BFS 几天的超时... A*算法不会,哪天再看去了. /* 倒搜超时, 改成顺序搜超时 然后把记录路径改成只记录当前点的操作,把上次的位置记录下AC..不完整的人生啊 */ #include < ...
- 团队作业-Beta冲刺第一天
这个作业属于哪个课程 <https://edu.cnblogs.com/campus/xnsy/SoftwareEngineeringClass1> 这个作业要求在哪里 <https ...
- jQuery中ready方法的实现
https://blog.csdn.net/major_zhang/article/details/80146674 先普及一下jquery.ready()和window.onload,window. ...
- 转 在Qt中用QAxObject来操作Excel
最近写程序中需要将数据输出保存到Excel文件中.翻看<C++ GUI Programming with Qt 4>(Second Edition)发现可以在Qt中运用ActiveX控件, ...