2016"百度之星" - 资格赛(Astar Round1) Problem E
简单模拟题,耐心写就能过。
#include <stdio.h>
#include <math.h>
#include<cstring>
#include<cmath>
#include<map>
#include<string>
#include<algorithm>
#include<vector>
using namespace std; const int INF=;
int n;
struct X
{
char s[];
int L[],R[];
} h[+]; map<string,int>m;
int cnt;
char tmp[]; char Na[];
int op,num;
int L,R; void get()
{
memset(Na,,sizeof Na);
int i;
for(i=; tmp[i]; i++)
{
if(tmp[i]==' ') continue;
else break;
} int g=;
for(; tmp[i]; i++)
{
if(tmp[i]>='a'&&tmp[i]<='z') Na[g++]=tmp[i];
else break;
} for(; tmp[i]; i++)
{
if(tmp[i]==' ') continue;
else break;
} if(tmp[i]=='<')
{
if(tmp[i+]=='=') op=;
else op=;
}
if(tmp[i]=='=') op=;
if(tmp[i]=='>')
{
if(tmp[i+]=='=') op=;
else op=;
} num=;
int u=;
for(; tmp[i]; i++)
{
if(tmp[i]=='-') u=-;
if(tmp[i]>=''&&tmp[i]<='') num=num*+tmp[i]-'';
}
num=num*u; if(op==) L=R=num;
else if(op==) L=-INF,R=num-,op=;
else if(op==) L=-INF,R=num;
else if(op==) L=num,R=INF;
else if(op==) L=num+,R=INF,op=;
} bool check(int a,int b)
{
for(int i=; i<=; i++)
{
if(h[a].L[i]==-) return ;
if(h[b].L[i]==-) return ;
} for(int i=; i<=; i++)
{
if(h[a].R[i]<h[b].L[i]) return ;
if(h[a].L[i]>h[b].R[i]) return ;
}
return ;
} int main()
{
while(~scanf("%d",&n))
{
getchar();
m.clear();
cnt=;
for(int i=; i<=n; i++) gets(h[i].s);
for(int i=; i<=n; i++)
{
int len=strlen(h[i].s);
char name[];
int tot=;
memset(name,,sizeof name);
for(int j=; j<len; j++)
{
if(h[i].s[j]>='a'&&h[i].s[j]<='z') name[tot++]=h[i].s[j];
else
{
if(name[]==) continue;
if(m[name]==) m[name]=++cnt;
tot=;
memset(name,,sizeof name);
}
}
} for(int i=; i<=n; i++)
{
int len=strlen(h[i].s);
int pos=;
memset(tmp,,sizeof tmp);
int f=; for(int j=; j<=; j++) h[i].L[j]=-INF,h[i].R[j]=INF; while(pos<=len)
{
if(h[i].s[pos]==','||h[i].s[pos]==)
{
get(); if(h[i].L[m[Na]]!=-)
{
if(op==)
{
if(R<h[i].L[m[Na]]) h[i].L[m[Na]]=h[i].R[m[Na]]=-;
else h[i].R[m[Na]]=min(h[i].R[m[Na]],R);
}
if(op==)
{
if(h[i].L[m[Na]]<=L&&L<=h[i].R[m[Na]]) h[i].L[m[Na]]=h[i].R[m[Na]]=L;
else h[i].L[m[Na]]=h[i].R[m[Na]]=-;
}
if(op==)
{
if(L>h[i].R[m[Na]]) h[i].L[m[Na]]=h[i].R[m[Na]]=-;
else h[i].L[m[Na]]=max(h[i].L[m[Na]],L);
}
}
memset(tmp,,sizeof tmp);
f=;
}
else tmp[f++]=h[i].s[pos];
pos++;
}
} for(int i=; i<=n; i++)
{
bool fail=;
vector<int>v; for(int j=; j<i; j++)
if(check(j,i))
{
fail=;
v.push_back(j);
} if(fail==) printf("unique\n");
else
{
for(int j=; j<v.size(); j++)
{
printf("%d",v[j]);
if(j<v.size()-) printf(" ");
else printf("\n");
}
}
}
}
return ;
}
2016"百度之星" - 资格赛(Astar Round1) Problem E的更多相关文章
- HDU 5688:2016"百度之星" - 资格赛 Problem D
原文链接:https://www.dreamwings.cn/hdu5688/2650.html Problem D Time Limit: 2000/1000 MS (Java/Others) ...
- HDU 5686:2016"百度之星" - 资格赛 Problem B
原文链接:https://www.dreamwings.cn/hdu5686/2645.html Problem B Time Limit: 2000/1000 MS (Java/Others) ...
- HDU 5685:2016"百度之星" - 资格赛 Problem A
原文链接:https://www.dreamwings.cn/hdu5685/2637.html Problem A Time Limit: 2000/1000 MS (Java/Others) ...
- 2016百度之星 资格赛ABCDE
看题:http://bestcoder.hdu.edu.cn/contests/contest_show.php?cid=690 交题:http://acm.hdu.edu.cn/search.php ...
- 2016"百度之星" - 资格赛(Astar Round1) Problem C
字典树. 插入的时候update一下节点出现的次数. delete的时候,先把前缀之后的全删了.然后看前缀最后一个节点出现了几次,然后前缀上每个节点的次数都减去这个次数. 前缀从上到下再检查一遍,如果 ...
- 2016"百度之星" - 资格赛(Astar Round1) Problem D
排个序,map直接搞. #include <stdio.h> #include <math.h> #include<cstring> #include<cma ...
- 2016"百度之星" - 资格赛(Astar Round1) Problem B
规律题,斐波那契数列,数据有毒,0的时候输出换行.会爆longlong,写个大数模板或者Java搞. import java.io.BufferedInputStream; import java.m ...
- 2016"百度之星" - 资格赛(Astar Round1) Problem A
保存前缀乘,询问的时候输出c[ri]/c[li-1]即可,因为是除法,所以计算一下c[li-1]的逆元. #include <stdio.h> #include <math.h> ...
- 2016"百度之星" - 资格赛(Astar Round1)
逆元 1001 Problem A 求前缀哈希和逆元 #include <bits/stdc++.h> typedef long long ll; const int MOD = 9973 ...
随机推荐
- Mysql:输出到文件
mysql>tee /home/a.txt mysql>show processlist; mysql>exit tee命令能重定向输出,同时屏幕会同步显示.
- .net项目svn项目管理文件清单
You can add the following files to Visual Studio source control: Solution files (*.sln). Project fil ...
- KMP算法中的next数组求解示意图
- js获取url传递参数,js获取url?号后面的参数
方法一.正则表达式 function getQueryString(name) { var reg = new RegExp("(^|&)" + name + " ...
- 近十年one-to-one最短路算法研究整理【转】
前言:针对单源最短路算法,目前最经典的思路即标号算法,以Dijkstra算法和Bellman-Ford算法为根本演进了各种优化技术和算法.针对复杂网络,传统的优化思路是在数据结构和双向搜索上做文章,或 ...
- PHP的几个常用加密函数【转载】
转自 https://jellybool.com/post/php-encrypt-functions 在网站的开发过程中,常常需要对部分数据(如用户密码)进行加密,本文主要介绍PHP的几个常见的加密 ...
- 滚动视图UIScrollView
int i; @interface ViewController () @end @implementation ViewController - (void)viewDidLoad { [super ...
- Response.Flush()
Response.Buffer=True就是在缓存网页 访问网站一般是程序直接输出网页结果,或从缓存中读取网页结果2种方式.两种方式在速度上是有差异的 设置 Response.Buffer = Tru ...
- 软件开发常用的linux命令心得(ubuntu为例)
软件开发过程中难免要经常对主机进行配置或者部署等操作,想到一些就写一些了,以后再更新 解压命令: a.如果是tar文件,则直接用 “tar zxvf 文件名”: b.如果是zip文件,用 “unzip ...
- Provisioning profile 浅析
转载自: http://blog.csdn.net/chenyufeng1991/article/details/48976245 一般在我们代码编写中不会用到Provisioning prof ...