标签:script explore body for pos pre field ems .com
Time Limit: 1000MS | Memory Limit: 10000K | |
Total Submissions: 8049 | Accepted: 3357 |
Description
Input
Output
Sample Input
2 0010011101001011 0100011011001011 0100101100100111 0011000111010101
Sample Output
same different
Source
1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 #include <cstdlib> 5 #include <string> 6 #include <vector> 7 #include <algorithm> 8 std::string s1, s2; 9 int t; 10 std::string dfs(std::string now) 11 { 12 std::vector<std::string> s; 13 std::string re = ""; 14 int flag = 0, pre = 1; 15 for(register int i = 0;i < now.size();++ i) 16 { 17 if(now[i] == ‘0‘)++ flag; 18 else -- flag; 19 if(flag == 0) 20 { 21 std::string tmp = dfs(now.substr(pre, i - pre)); 22 if(tmp == "")s.push_back("01"); 23 else s.push_back(‘0‘ + tmp + ‘1‘); 24 pre = i + 2; 25 } 26 } 27 std::sort(s.begin(), s.end()); 28 for(register int i = 0;i < s.size();++ i)re += s[i]; 29 return re; 30 } 31 int main() 32 { 33 scanf("%d", &t); 34 for(;t;-- t) 35 { 36 std::cin >> s1 >> s2; 37 if(dfs(s1) == dfs(s2))printf("same\n"); 38 else printf("different\n"); 39 } 40 return 0; 41 }
标签:script explore body for pos pre field ems .com
原文地址:http://www.cnblogs.com/huibixiaoxing/p/7477976.html