#include <cstdio> #include <iostream> #include <algorithm> #include <cstring> #include <vector> using namespace std; const int N = 1e2 + 10; const int INF = 0x3f3f3f3f; string s; int main(void) { int T; scanf ("%d", &T); getchar (); while (T--) { int x1 = 0, y1 = 0, x2 = 0, y2 = 0, x3 = 0; getline (cin, s); int len = s.length (); int c = 0; if (s[26] == ‘h‘) { int k = 44; while (k < len && s[k] >= ‘0‘ && s[k] <= ‘9‘) x1 = x1 * 10 + s[k++] - ‘0‘; bool flag = false; for (int i=k; i<len; ++i) { if (s[i] < ‘0‘ || s[i] > ‘9‘) { if (!flag) continue; else break; } else { flag = true; y1 = y1 * 10 + s[i] - ‘0‘; } } if (x1 > y1) { x2 = 0; } else if (x1 == y1) { x2 = 0; if (x2 < y1) x2++; } else if (x1 < y1) { x2 = y1 - x1; if (x2 < y1) x2++; } x3 = y1 + 30 - x1; if (x3 > y1) x3--; x3 = min (x3, 30); cout << x2 << " " << x3 << endl; } else { int k = 44; while (k < len && s[k] >= ‘0‘ && s[k] <= ‘9‘) x1 = x1 * 10 + s[k++] - ‘0‘; bool flag = false; for (int i=k; i<len; ++i) { if (s[i] < ‘0‘ || s[i] > ‘9‘) { if (!flag) continue; else break; } else { flag = true; y1 = y1 * 10 + s[i] - ‘0‘; } } if (x1 > y1) { x2 = 0; } else if (x1 == y1) { x2 = 0; } else if (x1 < y1) { x2 = y1 - x1; } x3 = y1 + 30 - x1; x3 = min (x3, 30); cout << x2 << " " << x3 << endl; } } return 0; }
时间: 2024-11-01 10:26:49