Two teams meet in The Game World Championship. Some scientists consider this game to be the most intellectually challenging game in the world. You are given two strings describing the teams' actions in the final battle. Figure out who became the champion.
The input contains two strings of equal length (between 2 and 20 characters, inclusive). Each line describes the actions of one team.
Output "TEAM 1 WINS" if the first team won, "TEAM 2 WINS" if the second team won, and "TIE" if there was a tie.
[]()[]8< 8<[]()8<
TEAM 2 WINS
8<8<() []8<[]
TIE
#include<stdio.h> #include<iostream> #include<string.h> #include<string> #include<ctype.h> #include<math.h> #include<set> #include<map> #include<vector> #include<queue> #include<bitset> #include<algorithm> #include<time.h> using namespace std; void fre() { freopen("c://test//input.in", "r", stdin); freopen("c://test//output.out", "w", stdout); } #define MS(x,y) memset(x,y,sizeof(x)) #define MC(x,y) memcpy(x,y,sizeof(x)) #define MP(x,y) make_pair(x,y) #define ls o<<1 #define rs o<<1|1 typedef long long LL; typedef unsigned long long UL; typedef unsigned int UI; template <class T1, class T2>inline void gmax(T1 &a, T2 b) { if (b>a)a = b; } template <class T1, class T2>inline void gmin(T1 &a, T2 b) { if (b<a)a = b; } const int N = 100, M = 0, Z = 1e9 + 7, ms63 = 0x3f3f3f3f; char a[N], b[N]; //8< 剪刀 //[] 石头 //() 布 int check() { int ret = 0; for (int i = 0; a[i]; i += 2) { if (a[i] == b[i]); else if (a[i] == '8') { if (b[i] == '[')++ret; if (b[i] == '(')--ret; } else if(a[i]=='[') { if (b[i] == '(')++ret; if (b[i] == '8')--ret; } else { if (b[i] == '8')++ret; if (b[i] == '[')--ret; } } return ret; } int main() { while (~scanf("%s%s", a,b)) { int ans=check(); if (ans == 0)puts("TIE"); else puts(ans > 0 ? "TEAM 1 WINS" : "TEAM 2 WINS"); } return 0; } /* 【trick&&吐槽】 要从题目信息找突破—— this game to be the most intellectually challenging game in the world 并不是括号匹配啊。我个傻叉>_< 【题意】 剪刀石头布,真的很像。 【类型】 脑洞 */