2016百度之星资格赛 E题
来源:互联网 发布:windows聚焦 win7 编辑:程序博客网 时间:2024/05/14 20:51
Problem E
Accepts: 170
Submissions: 804
Time Limit: 2000/1000 MS (Java/Others)
Memory Limit: 65536/65536 K (Java/Others)
unique1unique1 2
暴力,无他解法
#include<iostream>#include<cstdio>#include<cstring>using namespace std;#define INF 10005struct g{int flag;int sum;char one[40][40];int tw1[40], tw2[40];int three[40];g(){flag = 0;sum = 0;for (int i = 1; i <= 35; i++){tw1[i] = -INF;tw2[i] = INF;}}}a[1010];void Union(char temp2[40], int temp4, int i, int x){if (strcmp(temp2, "==") == 0){if (temp4 >= a[x].tw1[i] && temp4 <= a[x].tw2[i])a[x].tw1[i] = a[x].tw2[i] = temp4;elsea[x].flag = 1;}else if (strcmp(temp2, ">") == 0){temp4++;if (temp4 >= a[x].tw1[i] && temp4 <= a[x].tw2[i])a[x].tw1[i] = temp4;else if (temp4<a[x].tw1[i]);elsea[x].flag = 1;}else if (strcmp(temp2, ">=") == 0){if (temp4 >= a[x].tw1[i] && temp4 <= a[x].tw2[i])a[x].tw1[i] = temp4;else if (temp4<a[x].tw1[i]);elsea[x].flag = 1;}else if (strcmp(temp2, "<") == 0){temp4--;if (temp4 >= a[x].tw1[i] && temp4 <= a[x].tw2[i])a[x].tw2[i] = temp4;else if (temp4>a[x].tw2[i]);elsea[x].flag = 1;}else{if (temp4 >= a[x].tw1[i] && temp4 <= a[x].tw2[i])a[x].tw2[i] = temp4;else if (temp4>a[x].tw2[i]);elsea[x].flag = 1;}}void deal(char temp1[40], char temp2[40], char temp3[40], int x, int num){int len = strlen(temp3), i;int temp4 = 0;i = 0;if (temp3[0] == '-')i = 1;for (; i<len; i++)temp4 = 10 * temp4 + temp3[i] - '0';if (temp3[0] == '-')temp4 *= -1;for (i = 1; i <= num; i++)if (strcmp(a[x].one[i], temp1) == 0){Union(temp2, temp4, i, x);break;}if (i == num + 1){a[x].sum++;strcpy(a[x].one[i], temp1);Union(temp2, temp4, i, x);}}void ans(int x){int arg[1010], l = 0, sign;if (a[x].flag == 1){printf("unique\n");return;}for (int i = 1; i<x; i++){sign = 0;if (a[i].flag == 1)continue;for (int j = 1; j <= a[x].sum; j++){for (int k = 1; k <= a[i].sum; k++)if (strcmp(a[x].one[j], a[i].one[k]) == 0)if (a[x].tw2[j]<a[i].tw1[k] || a[i].tw2[k]<a[x].tw1[j]){sign = 1;break;}if (sign == 1)break;}if (sign == 0)arg[l++] = i;}if (l == 0){printf("unique\n");return;}else{for (int i = 0; i<l; i++)if (i == l - 1)printf("%d\n", arg[i]);elseprintf("%d ", arg[i]);}}int main(){int n, ph;char b[300], temp1[40], temp2[40], temp3[40];cin >> n;getchar();for (int i = 1; i <= n; i++){gets(b);ph = 0;int len = strlen(b);for (int j = 0; j<len;){if (b[j] == ' ' || b[j] == ','){j++;continue;}if (ph == 0){int k = 0;while (j<len && b[j] != ' ' && b[j] != ',')temp1[k++] = b[j++];temp1[k] = '\0';ph = 1;}else if (ph == 1){int k = 0;while (j<len && b[j] != ' ' && b[j] != ',')temp2[k++] = b[j++];temp2[k] = 0; ph = 2;}else{int k = 0;while (j<len && b[j] != ' ' && b[j] != ',')temp3[k++] = b[j++];temp3[k] = 0;ph = 0;if (a[i].flag == 0)deal(temp1, temp2, temp3, i, a[i].sum);}}ans(i);}return 0;}
1 0
- 2016百度之星资格赛E题
- 2016百度之星资格赛 E题
- 百度之星资格赛 E题 C++ 与Java
- 百度之星资格赛E题:C++与Java
- 百度之星资格赛——E题
- 百度之星资格赛 E题 C++ 与Java
- 2016"百度之星" - 资格赛(Astar Round1)Problem E(复杂模拟题)
- 2016百度之星资格赛 A题
- 2016百度之星资格赛 B题
- 2016百度之星资格赛 C题
- 2016百度之星资格赛 D题
- 2016百度之星资格赛D题
- 2016百度之星资格赛 B题
- 百度之星2016 资格赛D题
- 2016 百度之星 资格赛
- 2016百度之星资格赛
- 2016百度之星资格赛
- 2016百度之星资格赛
- JAVA基础之包装类,static,final,abstract ,接口 和 内部类
- PPT怎么插入图案填充效果
- UVa 1606 两亲性分子 扫描法
- Unity:Navmesh
- C/C++与Matlab混合编程
- 2016百度之星资格赛 E题
- 测试如何在博客中加入代码
- java基础知识学习
- hadoop 新API与旧API对比
- 致我亲爱的你
- 机器学习竞赛技巧
- L2-008. 最长对称子串
- android ListView的简单使用与优化
- Problem H: Eat Candy