UVa1596 - Bug Hunt
来源:互联网 发布:淘宝一千零一夜第二季 编辑:程序博客网 时间:2024/05/20 05:56
#include<iostream>#include<string>#include<sstream>#include<map>using namespace std;string s0, s, s1, s2, left_value,right_value;int bug;map<string, unsigned int> a;map<string, string> value;string get_value(string x, string arr){ unsigned int t = 0; string y, z; if(x.find("[") == string::npos){ stringstream ss(x); ss >> t; if(arr != s0 && t >= a[arr]) bug = 1; return x; } y = x.substr(0, x.find("[")); z = x.substr(x.find("[")+1, x.find_last_of("]") - 2); z = get_value(z, y); if(bug) return s0; x = y + "[" + z + "]"; if( !value.count(x) ) bug = 1; return value[x];}void get_arr(){ string x, y; unsigned int z; x = s.substr(0, s.find("[")); y = s.substr(s.find("[")+1, s.find_last_of("]")); y = get_value(y, s0); stringstream ss(y); ss >> z; a[x] = z; return;}int main(){ int flag = 0, cnt = 1; a[s0] = 0; string arr, indx; while( cin >> s ){ if(s != ".") flag = 1; else if(!flag) break; else { if(!bug) cout << "0" << endl; a.clear(); value.clear(); left_value = right_value = s0; cnt = 1; bug = flag = 0; continue; } if(bug) continue; if(s.find("=") == string::npos) get_arr(); else{ s1 = s.substr(0, s.find("=")); s2 = s.substr(s.find("=")+1); arr = s1.substr(0, s1.find("[")); indx = s1.substr(s1.find("[")+1, s1.find_last_of("]") - 2); indx = get_value(indx, arr); stringstream ss(indx); unsigned int t; ss >> t; if(t >= a[arr]) bug = 1; left_value = arr + "[" + indx + "]"; right_value = get_value(s2, s0); if(bug){ cout << cnt << endl; continue; } value[left_value] = right_value; left_value = right_value = s0; } cnt++; } return 0;}
0 0
- UVa1596 - Bug Hunt
- UVA1596 Bug Hunt
- 习题5-9 找bug(Bug Hunt, UVa1596)
- 算法竞赛入门经典 第二版 习题5-9 找bug Bug Hunt uva1596
- [刷题]算法竞赛入门经典(第2版) 5-9/UVa1596 - Bug Hunt
- POJ 3524 Bug Hunt
- UVa 1596 - Bug Hunt
- 1596 - Bug Hunt
- UVa 1596 - Bug Hunt
- UVa:1596 - Bug Hunt
- 1596 - Bug Hunt【STL】
- UVa-1596-Bug Hunt
- UVA 1596 Bug Hunt
- 1596 - Bug Hunt
- UVA1597--Bug Hunt
- Bug Hunt UVA
- UVA 1596 Bug Hunt
- UVa 1596 - Bug Hunt(细节)
- Best Time to Buy and Sell Stock III
- STL里的multimap使用简介
- find_last_of()
- 高等几何——周兴和答案2(自己写的,非标准答案,望指正)
- HDU1247--Hat’s Words【STL--map】
- UVa1596 - Bug Hunt
- leetcode Divide Two Integers
- cookie、session、sessionid 与jsessionid
- 分书问题
- uva 10057 A mid-summer night’s dream(中位数)
- Android之fragment介绍及fragment详解
- com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxError Exception
- 解决android开发中eclipse不能自动提示
- 用jquery解析JSON数据的方法