solution
stringlengths
11
983k
difficulty
int64
0
21
language
stringclasses
2 values
#include <bits/stdc++.h> using namespace std; template <class T> inline void read(T& x) { bool fu = 0; char c; for (c = getchar(); c <= 32; c = getchar()) ; if (c == '-') fu = 1, c = getchar(); for (x = 0; c > 32; c = getchar()) x = x * 10 + c - '0'; if (fu) x = -x; }; inline char getc() { char c; for (c = getchar(); c <= 32; c = getchar()) ; return c; } int n, i, j, k, p; int V[110][110], l[110], r[110]; int ans1, ans2, c[110]; int main() { read(n); for (i = 1; i <= n; i++) { read(V[i][0]); for (j = 1; j <= V[i][0]; j++) read(V[i][j]); for (j = 1; j <= V[i][0] / 2; j++) ans1 += V[i][j]; for (j = V[i][0]; j >= V[i][0] - (V[i][0] / 2) + 1; j--) ans2 += V[i][j]; if (V[i][0] & 1) c[++c[0]] = V[i][(V[i][0] + 1) / 2]; } sort(c + 1, c + 1 + c[0], greater<int>()); for (i = 1; i <= n; i++) if (i & 1) ans1 += c[i]; else ans2 += c[i]; printf("%d %d\n", ans1, ans2); scanf("\n"); return 0; }
9
CPP
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int ciel = 0, jiro = 0; vector<int> mid; for (int i = 0; i < n; i++) { int sz; cin >> sz; int j; for (j = 0; j < sz / 2; j++) { int num; cin >> num; ciel += num; } if (sz % 2 == 1) { int num; cin >> num; mid.push_back(num); j++; } for (; j < sz; j++) { int num; cin >> num; jiro += num; } } sort(mid.begin(), mid.end()); int sz = mid.size(); for (int i = sz - 1; i >= 0; i--) { if ((sz - i) % 2 == 1) ciel += mid[i]; else jiro += mid[i]; } cout << ciel << " " << jiro << "\n"; return 0; }
9
CPP
#include <bits/stdc++.h> using namespace std; int n; vector<int> v; int a[1000]; long long ansl = 0, ansr = 0; void solve() { scanf("%d", &n); for (int i = 0; i < n; ++i) { int m; scanf("%d", &m); for (int j = 0; j < m; ++j) scanf("%d", &a[j]); for (int j = 0; j < m / 2; ++j) ansl += a[j], ansr += a[m - j - 1]; if (m % 2) v.push_back(a[m / 2]); } sort(v.begin(), v.end()); for (int i = v.size() - 1, j = 0; i >= 0; --i, ++j) if (j % 2) ansr += v[i]; else ansl += v[i]; cout << ansl << ' ' << ansr << endl; } int main() { solve(); return 0; }
9
CPP
from functools import reduce n = int(input()) cards = [list(map(int, input().split()[1:])) for i in range(n)] mid = sorted((c[len(c) >> 1] for c in cards if len(c) & 1 == 1), reverse=True) add = lambda x=0, y=0: x + y a, b = reduce(add, mid[::2] or [0]), reduce(add, mid[1::2] or [0]) for c in cards: m = len(c) >> 1 a += reduce(add, c[:m] or [0]) b += reduce(add, c[m + (len(c) & 1):] or [0]) print(a, b)
9
PYTHON3
#include <bits/stdc++.h> int odd_mid[100]; int main() { int n; scanf("%d", &n); int odd_n = 0; std::pair<int, int> ans(0, 0); for (int i = 0; i < n; i++) { int s, c; scanf("%d", &s); for (int j = 0; j < s / 2; j++) { scanf("%d", &c); ans.first += c; } if (s % 2) { scanf("%d", &c); odd_mid[odd_n++] = c; } for (int j = (s + 1) / 2; j < s; j++) { scanf("%d", &c); ans.second += c; } } std::sort(odd_mid, odd_mid + odd_n); for (int i = 0; i < odd_n; i++) { if (i % 2 == 0) ans.first += odd_mid[odd_n - i - 1]; else ans.second += odd_mid[odd_n - i - 1]; } printf("%d %d\n", ans.first, ans.second); return 0; }
9
CPP
#include <bits/stdc++.h> using namespace std; int n, s, arr[105]; int foxSum, totalSum, ct, foxCt; vector<int> extras; int main(int argc, const char* argv[]) { cin >> n; for (int i = 0; i < n; i++) { cin >> s; ct += s; foxCt += s / 2; for (int j = 0; j < s; j++) { cin >> arr[j]; totalSum += arr[j]; } for (int j = 0; j < s / 2; j++) foxSum += arr[j]; if (s % 2 == 1) extras.push_back(arr[s / 2]); } sort(extras.begin(), extras.end()); for (int i = 0; i < (ct + 1) / 2 - foxCt; i++) { foxSum += extras[extras.size() - 1 - 2 * i]; } cout << foxSum << " " << totalSum - foxSum << endl; return 0; }
9
CPP
#include <bits/stdc++.h> using namespace std; int arr[100010], cnt; int n, k, x; long long sum1, sum2; int main() { scanf("%d", &n); for (int i = 1; i <= n; i++) { scanf("%d", &k); for (int i = 1; i <= k; i++) { scanf("%d", &x); if (i <= k / 2) sum1 += x; else if (i * 2 == k + 1) { arr[cnt++] = x; } else sum2 += x; } } sort(arr, arr + cnt, greater<int>()); for (int i = 0; i < cnt; i++) { if (i & 1) sum2 += arr[i]; else sum1 += arr[i]; } cout << sum1 << " " << sum2 << endl; }
9
CPP
#include <bits/stdc++.h> using namespace std; int a[100]; void qs(int q, int w) { int e = q, r = w, t = a[q + (rand() % (w - q + 1))], y; do { while (a[e] > t) e++; while (a[r] < t) r--; if (e <= r) { y = a[e]; a[e] = a[r]; a[r] = y; e++; r--; } } while (e <= r); if (q < r) qs(q, r); if (e < w) qs(e, w); } int main() { int q, w, e, r, t = 0, c = 0, v = 0; for (cin >> q; q; q--) { cin >> w; for (e = 0; e < w / 2; e++) { cin >> r; c += r; } if (w % 2) { cin >> a[t]; t++; } for (e = 0; e < w / 2; e++) { cin >> r; v += r; } } if (t) qs(0, t - 1); for (w = 0; w < t; w++) if (w % 2) v += a[w]; else c += a[w]; cout << c << " " << v; return 0; }
9
CPP
#include <bits/stdc++.h> int comparar(const void* a, const void* b); int main(void) { int n, i, j, carta, puntajeCiel = 0, puntajeJiro = 0, m, sobra = 0; scanf("%d", &n); int medio[n]; for (i = 0; i < n; ++i) { scanf("%d", &m); for (j = 0; j < m; ++j) { scanf("%d", &carta); if (j < m / 2) { puntajeCiel += carta; } else if ((m % 2 == 1) && (j == m / 2)) { medio[sobra++] = carta; } else puntajeJiro += carta; } } qsort(medio, sobra, sizeof(int), comparar); for (i = 0; i < sobra; ++i) { if (i % 2 == 0) puntajeCiel += medio[i]; else puntajeJiro += medio[i]; } printf("%d %d", puntajeCiel, puntajeJiro); } int comparar(const void* a, const void* b) { return (*(int*)b - *(int*)a); }
9
CPP
#include <bits/stdc++.h> void ordenacionshell(int v[], int n); int main() { int n, i, tam, ciel = 0, jiro = 0, m = 0, j; scanf("%d", &n); int v[n]; for (i = 0; i < n; i++) { v[i] = 0; } for (i = 0; i < n; i++) { scanf("%d", &tam); int pila[tam]; if (tam % 2 == 0) { for (j = 0; j < tam; j++) { scanf("%d", &pila[j]); if (j < tam / 2) { ciel = ciel + pila[j]; } else { jiro = jiro + pila[j]; } } } else { for (j = 0; j < tam; j++) { scanf("%d", &pila[j]); if (j < tam / 2) { ciel = ciel + pila[j]; } else if (j > tam / 2) { jiro = jiro + pila[j]; } else { v[m] = pila[j]; m++; } } } } ordenacionshell(v, n); i = 0; while (i < m) { if (i % 2 == 0) { ciel = ciel + v[i]; } else { jiro = jiro + v[i]; } i++; } printf("%d %d", ciel, jiro); return 0; } void ordenacionshell(int v[], int n) { int intervalo, i, j, k; int temp; intervalo = n / 2; while (intervalo > 0) { for (i = intervalo; i < n; i++) { j = i - intervalo; while (j >= 0) { k = j + intervalo; if (v[j] >= v[k]) { j = -1; } else { temp = v[j]; v[j] = v[k]; v[k] = temp; j -= intervalo; } } } intervalo = intervalo / 2; } }
9
CPP
#include <bits/stdc++.h> using namespace std; long long int n, s, x, cnt1, cnt2; vector<int> vect; int main() { cin >> n; while (n--) { cin >> s; for (int i = 0; i < s / 2; i++) cin >> x, cnt1 += x; if (s % 2) cin >> x, vect.push_back(x); for (int i = 0; i < s / 2; i++) cin >> x, cnt2 += x; } sort(vect.begin(), vect.end()); for (int i = vect.size() - 1; i >= 0; i--) (vect.size() - i) % 2 ? cnt1 += vect[i] : cnt2 += vect[i]; cout << cnt1 << ' ' << cnt2 << endl; }
9
CPP
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; const int maxe = 1e6 + 85; long long n, a, b, k; vector<int> v; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n; for (int i = 0; i < n; i++) { int s; cin >> s; for (int j = 0; j < s / 2; j++) { int c; cin >> c; a += c; } if (s % 2) { int c; cin >> c; v.push_back(-c); } for (int j = 0; j < s / 2; j++) { int c; cin >> c; b += c; } } sort(v.begin(), v.end()); for (int i = 0; i < v.size(); i++) { if (i % 2) { b += -v[i]; } else { a += -v[i]; } } cout << a << ' ' << b; return 0; }
9
CPP
#include <bits/stdc++.h> using namespace std; int a[150]; int ans[150]; bool cmp(int s1, int s2) { return s1 > s2; } int main() { int n; cin >> n; int s1 = 0, s2 = 0; int cnt = 0; while (n--) { int t; cin >> t; for (int i = 1; i <= t; i++) { cin >> a[i]; } for (int i = 1; i <= t / 2; i++) { s1 += a[i]; s2 += a[t - i + 1]; } if (t % 2 != 0) { ans[cnt++] = a[t / 2 + 1]; } } sort(ans, ans + cnt, cmp); for (int i = 0; i < cnt; i++) { if (i % 2 == 0) s1 += ans[i]; else s2 += ans[i]; } printf("%d %d\n", s1, s2); }
9
CPP
#include <bits/stdc++.h> typedef struct nodo { int dato; struct nodo *anterior; struct nodo *siguiente; } nodo; typedef struct pila { nodo *primero; nodo *ultimo; } mazos; void agregar(mazos *mazo, int valor); void CrearMazo(mazos *mazo, int n); void imprimir(mazos mazo[], int dim); void eliminar(mazos *mazo, nodo *actual); int main() { int n, i, j, valor, turno = 1, ciel = 0, mayor, jiro = 0, ban = 1, cont, indice; nodo *direccion; scanf("%d", &n); int x[n]; mazos mazo[n]; CrearMazo(mazo, n); for (i = 0; i < n; i++) { scanf("%d", &x[i]); for (j = 0; j < x[i]; j++) { scanf("%d", &valor); agregar(&mazo[i], valor); } } for (i = 0; i < n; i++) { if (x[i] % 2 == 0) { while (mazo[i].primero != NULL) { if (turno % 2 != 0) { ciel += mazo[i].primero->dato; eliminar(&mazo[i], mazo[i].primero); } else { jiro += mazo[i].ultimo->dato; eliminar(&mazo[i], mazo[i].ultimo); } turno++; } } else { while (mazo[i].primero != mazo[i].ultimo) { if (turno % 2 != 0) { ciel += mazo[i].primero->dato; eliminar(&mazo[i], mazo[i].primero); } else { jiro += mazo[i].ultimo->dato; eliminar(&mazo[i], mazo[i].ultimo); } turno++; } } } while (ban == 1) { ban = 0; indice = -1; mayor = 0; for (i = 0; i < n; i++) { if (mazo[i].primero != NULL) { if (turno % 2 == 0) { if (mayor < mazo[i].ultimo->dato) { mayor = mazo[i].ultimo->dato; direccion = mazo[i].ultimo; indice = i; } } else { if (mayor < mazo[i].primero->dato) { mayor = mazo[i].primero->dato; direccion = mazo[i].primero; indice = i; } } } } if (turno % 2 != 0 && indice != -1) { ciel += mayor; eliminar(&mazo[indice], direccion); ban = 1; } else if (turno % 2 == 0 && indice != -1) { jiro += mayor; eliminar(&mazo[indice], direccion); ban = 1; } turno++; } printf("%d %d", ciel, jiro); return 0; } void agregar(mazos *mazo, int valor) { nodo *nuevo = (nodo *)malloc(sizeof(nodo)); if (mazo->ultimo != NULL) { nuevo->anterior = mazo->ultimo; mazo->ultimo->siguiente = nuevo; } else { nuevo->anterior = NULL; mazo->primero = nuevo; } mazo->ultimo = nuevo; nuevo->siguiente = NULL; nuevo->dato = valor; } void CrearMazo(mazos *mazo, int n) { int i; for (i = 0; i < n; i++) { mazo[i].primero = NULL; mazo[i].ultimo = NULL; } } void imprimir(mazos mazo[], int dim) { int i; nodo *actual; for (i = 0; i < dim; i++) { actual = mazo[i].primero; while (actual != NULL) { printf("%d ", actual->dato); actual = actual->siguiente; } printf("\n"); } } void eliminar(mazos *mazo, nodo *actual) { nodo *temp = (nodo *)malloc(sizeof(nodo)); if (mazo->ultimo == mazo->primero) { mazo->primero = NULL; mazo->ultimo = NULL; temp = actual; } else { if (actual->siguiente == NULL) { actual->anterior->siguiente = NULL; mazo->ultimo = actual->anterior; } else { actual->siguiente->anterior = NULL; mazo->primero = actual->siguiente; } temp = actual; } free(temp); }
9
CPP
#include <bits/stdc++.h> using namespace std; const int INF = 1e9; const long long INF64 = 1e18; const double PI = acos(-1.0); const double EPS = 1e-8; const int MOD = 1000000007; const int N = 110; int n; vector<int> a[N]; int main() { int ans1 = 0, ans2 = 0; cin >> n; vector<int> mids; for (int i = 0; i < int(n); i++) { int m; cin >> m; a[i].resize(m); for (int j = 0; j < int(m); j++) { cin >> a[i][j]; } for (int l = 0, r = m - 1; l < r; l++, r--) { ans1 += a[i][l]; ans2 += a[i][r]; } if (m & 1) mids.push_back(a[i][m / 2]); } sort(mids.begin(), mids.end()); reverse(mids.begin(), mids.end()); for (int i = 0; i < int((int)mids.size()); i++) { if (i & 1) ans2 += mids[i]; else ans1 += mids[i]; } cout << ans1 << " " << ans2; return 0; }
9
CPP
#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<int, int>; using vi = vector<int>; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n; cin >> n; vector<int> vec; int clei = 0, jiro = 0; for (int i = 0; i < n; i++) { int s, e; cin >> s; int h = s / 2; for (int j = 0; j < h; j++) { cin >> e; clei += e; } if (s & 1) cin >> e, vec.push_back(e), h++; for (int j = h; j < s; j++) { cin >> e; jiro += e; } } sort((vec).rbegin(), (vec).rend()); int f = 1; for (int& e : vec) { if (f) clei += e; else jiro += e; f ^= 1; } cout << clei << " " << jiro << '\n'; }
9
CPP
#include <bits/stdc++.h> using namespace std; int n, s[110], a[110][110], b[110]; int main() { long long k; while (cin >> n) { int ans = 0; k = 0; for (int i = 1; i <= n; i++) { cin >> s[i]; int sum = 0, tot = 0; for (int j = 1; j <= s[i]; j++) { cin >> a[i][j]; if (j <= s[i] / 2) sum += a[i][j]; tot += a[i][j]; } k += tot; if (s[i] % 2 == 0) { b[i] = 1000000000; ans += sum - (tot - sum); } else { b[i] = a[i][s[i] / 2 + 1]; ans += sum - (tot - sum - b[i]); } } sort(b + 1, b + 1 + n); b[n + 1] = 1000000000; for (int i = 1; i <= n + 1; i++) { if (b[i] == 1000000000) { int ss = 1; while (--i) { ans += ss * b[i]; ss *= (-1); } break; } } cout << (k + ans) / 2 << " " << (k - ans) / 2 << endl; } }
9
CPP
#include <bits/stdc++.h> using namespace std; int n, m, c[150], s[150]; int main() { int cnt = 0, p = 0, q = 0; scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%d", &m); int tmp = m / 2; for (int j = 0; j < m; j++) { scanf("%d", &c[j]); if (j < tmp) p += c[j]; else q += c[j]; } if (m & 1) { q -= c[tmp]; s[cnt++] = c[tmp]; } } sort(s, s + cnt, greater<int>()); for (int i = 0; i < cnt; i++) { if (i & 1) q += s[i]; else p += s[i]; } printf("%d %d\n", p, q); return 0; }
9
CPP
#include <bits/stdc++.h> using namespace std; int record[110]; int final[110]; int Cnt; int main() { int heap; scanf("%d", &heap); int i, j; int ret1 = 0, ret2 = 0; for (i = 0; i < heap; i++) { int num, temp; scanf("%d", &num); for (j = 0; j < num / 2; j++) { scanf("%d", &temp); ret1 += temp; } if (num % 2) scanf("%d", &final[Cnt++]); for (j = 0; j < num / 2; j++) { scanf("%d", &temp); ret2 += temp; } } sort(final, final + Cnt); for (i = Cnt - 1; i >= 0; i--) { if ((Cnt - 1 - i) % 2 == 0) ret1 += final[i]; else ret2 += final[i]; } printf("%d %d\n", ret1, ret2); return 0; }
9
CPP
#include <bits/stdc++.h> using namespace std; inline long long read() { register long long x = 0, f = 0; register char c = getchar(); while (c < '0' || c > '9') { if (c == '-') f = 1; c = getchar(); } while (c >= '0' && c <= '9') x = (x << 3) + (x << 1) + (c ^ '0'), c = getchar(); return f ? -x : x; } inline void write(long long x) { if (x < 0) putchar('-'), x = -x; if (x > 9) write(x / 10); putchar(x % 10 + '0'); } const long long N = 201 + 10; long long n, s, c, ansa, ansb, f; priority_queue<long long> q; signed main() { n = read(); for (register long long i = 1; i <= n; ++i) { s = read(); for (register long long j = 1; j <= s; ++j) { c = read(); if ((s & 1) && j == (s + 1) / 2) q.push(c); else { if (j <= s / 2) ansa += c; else ansb += c; } } } while (!q.empty()) !f ? ansa += q.top() : ansb += q.top(), q.pop(), f ^= 1; cout << ansa << " " << ansb; return 0; }
9
CPP
#include <bits/stdc++.h> using namespace std; int a[105][105]; int k[105]; int main() { int n; scanf("%d", &n); int zuo = 0; int you = 0; int r = 0; for (int i = 0; i < n; i++) { int p; scanf("%d", &p); for (int j = 0; j < p; j++) scanf("%d", &a[i][j]); if (p % 2 == 0) { int u; for (u = 0; u < p / 2; u++) zuo += a[i][u]; for (; u < p; u++) you += a[i][u]; } else { int u; for (u = 0; u < p / 2; u++) zuo += a[i][u]; k[r++] = a[i][u++]; for (; u < p; u++) you += a[i][u]; } } sort(k, k + r); for (int i = r - 1; i >= 0; i--) { int j = r - 1 - i; if (j % 2 == 0) zuo += k[i]; else you += k[i]; } printf("%d %d\n", zuo, you); }
9
CPP
#include <bits/stdc++.h> using namespace std; int ciel, jiro, n, s, lim, tmp; vector<int> mVal; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n; for (int i = 0; i < n; i++) { cin >> s; if (s & 1) lim = (s - 1) >> 1; else lim = s >> 1; for (int j = 0; j < lim; j++) { cin >> tmp; ciel += tmp; } if (s & 1) { cin >> tmp; mVal.push_back(tmp); } for (int j = 0; j < lim; j++) { cin >> tmp; jiro += tmp; } } sort(mVal.begin(), mVal.end(), greater<int>()); for (int i = 0; i < mVal.size(); i++) { if (i & 1) jiro += mVal[i]; else ciel += mVal[i]; } cout << ciel << " " << jiro << "\n"; return 0; }
9
CPP
#include <bits/stdc++.h> using namespace std; int n, s, jum, x; int ar[105], ki[105], ka[105], gan[105], tem[105], tot[105]; int main() { memset(ar, 0, sizeof(ar)); memset(ki, 0, sizeof(ki)); memset(ka, 0, sizeof(ka)); memset(gan, 0, sizeof(gan)); memset(tem, 0, sizeof(tem)); scanf("%d", &n); for (int i = 1; i <= n; i++) { scanf("%d", &s); jum = 0; for (int j = 1; j <= s; j++) { scanf("%d", &x); jum += x; if (j <= s / 2) ki[i] += x; if (j > (s + 1) / 2) ka[i] += x; if (s % 2 != 0) if (j == (s + 1) / 2) gan[i] = x; } tot[i] = s; ar[i] = jum; } vector<pair<int, int> > v; vector<pair<int, int> > v2; for (int i = 1; i <= n; i++) if (gan[i] == 0) v.push_back(make_pair(ar[i], i)); else { v2.push_back(make_pair(gan[i], i)); } int ciel, jiro; ciel = jiro = 0; for (int i = 0; i < v.size(); i++) { ciel += ki[v[i].second]; jiro += ka[v[i].second]; } sort(v2.begin(), v2.end()); reverse(v2.begin(), v2.end()); int mark = 1; for (int i = 0; i < v2.size(); i++) { ciel += ki[v2[i].second]; jiro += ka[v2[i].second]; if (mark == 1) { ciel += v2[i].first; mark = 0; } else { jiro += v2[i].first; mark = 1; } } printf("%d %d\n", ciel, jiro); return 0; }
9
CPP
#include <bits/stdc++.h> using namespace std; int main() { int n, m, x, y, sz, i, j; scanf("%d", &n); vector<int> lft, right, mid; for (i = 0; i < n; ++i) { scanf("%d", &m); y = m / 2; for (j = 0; j < m; ++j) { scanf("%d", &x); if (j < y) lft.push_back(x); else if (m % 2 && j == y) mid.push_back(x); else right.push_back(x); } } int ans[2] = {}; ans[0] = accumulate(lft.begin(), lft.end(), 0); ans[1] = accumulate(right.begin(), right.end(), 0); sort(mid.rbegin(), mid.rend()); sz = mid.size(); for (i = 0; i < sz; ++i) { ans[i % 2] += mid[i]; } printf("%d %d\n", ans[0], ans[1]); return 0; }
9
CPP
#include <bits/stdc++.h> using namespace std; int main() { int n; long long sum1 = 0, sum2 = 0; vector<int> rem; scanf("%d", &n); while (n--) { int s; scanf("%d", &s); for (int i = 0; i < s; ++i) { int si; scanf("%d", &si); if (i == (s >> 1) && (s & 1)) rem.push_back(si); else if (i + 1 <= (s >> 1)) sum1 += si; else if (i + 1 > (s >> 1)) sum2 += si; } } sort(rem.begin(), rem.end(), greater<int>()); for (int i = 0; i < rem.size(); ++i) if (i & 1) sum2 += rem[i]; else sum1 += rem[i]; printf("%I64d %I64d", sum1, sum2); return 0; }
9
CPP
#include <bits/stdc++.h> using namespace std; int main() { int n; scanf("%d", &n); vector<int> odd; int sumA = 0, sumB = 0; for (int i = 0; i < n; ++i) { int k; scanf("%d", &k); vector<int> c(k); for (int i = 0; i < k; ++i) scanf("%d", &c[i]); int p = k / 2; for (int i = 0; i < p; ++i) sumA += c[i]; for (int i = k - p; i < k; ++i) sumB += c[i]; if (k % 2 == 1) odd.push_back(c[p]); } sort(odd.begin(), odd.end()); reverse(odd.begin(), odd.end()); for (int i = 0; i < odd.size(); ++i) if (i % 2 == 0) sumA += odd[i]; else sumB += odd[i]; printf("%d %d", sumA, sumB); return 0; }
9
CPP
#include <bits/stdc++.h> using namespace std; int vals[105][105]; int n; int cnt[105]; int p[105]; int k[105]; int mid(int p, int k, int id) { int m = (p + k) / 2; if ((k - p) % 2) if (id == 1) m++; return m; } int main() { scanf("%d", &n); for (int i = 1; i <= n; i++) { scanf("%d", &cnt[i]); for (int j = 1; j <= cnt[i]; j++) scanf("%d", &vals[i][j]); p[i] = 1; k[i] = cnt[i]; } int sp, sd; sp = sd = 0; int ok = 1; int it = 1; while (ok) { int mxid, mx; mx = -1000; for (int i = 1; i <= n; i++) if (p[i] <= k[i]) { int m = mid(p[i], k[i], it); if (vals[i][m] > mx) { mx = vals[i][m]; mxid = i; } } if (it == 1) { sp += vals[mxid][p[mxid]]; p[mxid]++; } else { sd += vals[mxid][k[mxid]]; k[mxid]--; } ok = 0; for (int i = 1; i <= n; i++) if (p[i] <= k[i]) ok = 1; it ^= 1; } printf("%d %d\n", sp, sd); }
9
CPP
#include <bits/stdc++.h> using namespace std; int n, total; int s[110], c[110][110]; pair<int, int> a[110]; bool chosen[110]; int main() { scanf("%d", &n); for (int i = 1; i <= n; i++) { scanf("%d", s + i); for (int j = 1; j <= s[i]; j++) { scanf("%d", c[i] + j); total += c[i][j]; } a[i] = make_pair(0, 0); int half = s[i] / 2 + s[i] % 2; for (int j = 1; j <= half; j++) { a[i].first += c[i][j]; a[i].second += c[i][s[i] - j + 1]; } for (int j = half + 1; j <= s[i]; j++) { a[i].first -= c[i][j]; a[i].second -= c[i][s[i] - j + 1]; } } memset(chosen, 0, sizeof chosen); int diff = 0; for (int step = 1; step <= n; step++) { int tmp = 0; if (step & 1) { for (int i = 1; i <= n; i++) if (!chosen[i]) tmp = max(tmp, a[i].first + a[i].second); for (int i = 1; i <= n; i++) if (!chosen[i] && tmp == a[i].first + a[i].second) { chosen[i] = 1; diff += a[i].first; break; } } else { for (int i = 1; i <= n; i++) if (!chosen[i]) tmp = max(tmp, a[i].first + a[i].second); for (int i = 1; i <= n; i++) if (!chosen[i] && tmp == a[i].first + a[i].second) { chosen[i] = 1; diff -= a[i].second; break; } } } printf("%d %d", (total + diff) / 2, (total - diff) / 2); return 0; }
9
CPP
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; const int NEGATIVE_INF = -INF; const int MAXN = 1010; bool cmp(const int &a, const int &b) { return a > b; } int n, s_size[105], s[105][105]; int dp[105][105]; int for_sort[105], fop = 0; int sum = 0; int ans1 = 0; int main() { ios_base::sync_with_stdio(false); cin.sync_with_stdio(false); cout.sync_with_stdio(false); cin >> n; for (int i = 1; i <= n; i++) { cin >> s_size[i]; for (int j = 1; j <= s_size[i]; j++) { cin >> s[i][j]; sum += s[i][j]; } } for (int i = 1; i <= n; i++) { for (int j = 1; j <= s_size[i] / 2; j++) ans1 += s[i][j]; if (s_size[i] % 2 != 0) for_sort[fop++] = s[i][(s_size[i] + 1) / 2]; } sort(for_sort, for_sort + fop, cmp); for (int i = 0; i < fop; i += 2) ans1 += for_sort[i]; cout << ans1 << " " << sum - ans1 << endl; return 0; }
9
CPP
#include <bits/stdc++.h> using namespace std; int n, x; int s[105]; int ciel, jiro; vector<int> mid; int main() { scanf("%d", &n); for (int i = 0; i < (n); i++) { scanf("%d", &s[i]); for (int j = 0; j < (s[i]); j++) { scanf("%d", &x); if ((2 * j + 1) == s[i]) mid.push_back(x); else if (j < s[i] / 2) ciel += x; else jiro += x; } } sort(mid.rbegin(), mid.rend()); for (int i = 0; i < (mid.size()); i++) if (i & 1) jiro += mid[i]; else ciel += mid[i]; printf("%d %d\n", ciel, jiro); return 0; }
9
CPP
#include <bits/stdc++.h> using namespace std; int a[111], b[111]; int main() { int n, x; scanf("%d", &n); int tot = 0, ans1 = 0, ans2 = 0; for (int i = 1; i <= n; i++) { scanf("%d", &x); for (int j = 0; j < x; j++) scanf("%d", &a[j]); for (int j = 0; j < x / 2; j++) ans1 += a[j]; if (x & 1) { for (int j = x / 2 + 1; j < x; j++) ans2 += a[j]; b[tot++] = a[x / 2]; } else { for (int j = x / 2; j < x; j++) ans2 += a[j]; } } sort(b, b + tot); reverse(b, b + tot); for (int i = 0; i < tot; i++) { if (i & 1) ans2 += b[i]; else ans1 += b[i]; } printf("%d %d\n", ans1, ans2); return 0; }
9
CPP
#include <bits/stdc++.h> using namespace std; int main() { int numofpiles; cin >> numofpiles; int ceilshare = 0; int jiroshare = 0; vector<int> pileconfig; vector<int> remaining; while (numofpiles--) { int n; cin >> n; pileconfig.clear(); for (int i = 0; i < n; i++) { int var; cin >> var; pileconfig.push_back(var); } if (n % 2 == 0) { for (int i = 0; i < n / 2; i++) ceilshare += pileconfig[i]; for (int i = n / 2; i < n; i++) jiroshare += pileconfig[i]; } else if (n % 2 != 0) { for (int i = 0; i < (n - 1) / 2; i++) ceilshare += pileconfig[i]; for (int i = (n + 1) / 2; i < n; i++) jiroshare += pileconfig[i]; remaining.push_back(pileconfig[n / 2]); } } int flag = 0; sort(remaining.begin(), remaining.end()); for (int i = remaining.size() - 1; i >= 0; i--) { if (flag == 0) { ceilshare += remaining[i]; flag = 1; } else if (flag == 1) { jiroshare += remaining[i]; flag = 0; } } cout << ceilshare << " " << jiroshare << "\n"; }
9
CPP
#include <bits/stdc++.h> using namespace std; const int maxn = 105; int n; vector<int> a[maxn]; int ans1, ans2; vector<int> v; int main() { cin >> n; for (int i = 0; i < n; i++) { int num; cin >> num; for (int j = 0; j < num; j++) { int tmp; cin >> tmp; a[i].push_back(tmp); } } for (int i = 0; i < n; i++) { if (a[i].size() % 2 == 0) { for (int j = 0; j < a[i].size(); j++) { if (j < ((int)a[i].size()) / 2) ans1 += a[i][j]; else ans2 += a[i][j]; } } else { for (int j = 0; j < a[i].size(); j++) { if (j == a[i].size() / 2) { v.push_back(a[i][j]); continue; } if (j < ((int)a[i].size()) / 2) ans1 += a[i][j]; else ans2 += a[i][j]; } } } sort(v.begin(), v.end()); reverse(v.begin(), v.end()); for (int i = 0; i < v.size(); i++) { if (i % 2 == 0) ans1 += v[i]; else ans2 += v[i]; } cout << ans1 << " " << ans2; return 0; }
9
CPP
#include <bits/stdc++.h> int cmpfunc(const void* a, const void* b) { return (*(int*)b - *(int*)a); } int main() { int i, j, k, medio, sumador1 = 0, sumador2 = 0, contador = 0, val = 0, n; scanf("%d", &n); int vec[n]; for (i = 0; i < n; i++) { scanf("%d", &j); medio = j / 2; for (k = 0; k < j; k++) { scanf("%d", &val); if (k < medio) sumador1 += val; else if (k == medio && j % 2 != 0) { vec[contador++] = val; } else sumador2 += val; } } qsort(vec, contador, sizeof(int), cmpfunc); for (i = 0; i < contador; i++) { if (i % 2 != 0) sumador2 += vec[i]; else sumador1 += vec[i]; } printf("%d %d", sumador1, sumador2); }
9
CPP
#include <bits/stdc++.h> using namespace std; void read(int &x) { char ch = getchar(); while (ch < '0' || ch > '9') ch = getchar(); for (x = 0; ch >= '0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - 48; } int n, m, a[1000], ans1, ans2, k, x; int main() { read(n); m = 0; for (int i = 1; i <= (n); ++i) { read(k); for (int j = 1; j <= (k); ++j) { read(x); if (k % 2 && j * 2 - 1 == k) a[++m] = x; else if (j * 2 <= k) ans1 += x; else ans2 += x; } } sort(a + 1, a + m + 1); int o(1); for (int i = (m); i >= (1); --i) { if (o == 1) ans1 += a[i]; else ans2 += a[i]; o = 3 - o; } printf("%d %d\n", ans1, ans2); return 0; }
9
CPP
#include <bits/stdc++.h> using namespace std; string a, b; int wa, wb; int main() { cin >> a >> b; for (int i = 0; i < a.size(); i += 2) { if (a[i] == '8' && b[i] == '[') wa++; if (a[i] == '[' && b[i] == '(') wa++; if (a[i] == '(' && b[i] == '8') wa++; if (b[i] == '8' && a[i] == '[') wb++; if (b[i] == '[' && a[i] == '(') wb++; if (b[i] == '(' && a[i] == '8') wb++; } if (wa > wb) puts("TEAM 1 WINS"); else if (wa < wb) puts("TEAM 2 WINS"); else puts("TIE"); return 0; }
7
CPP
#include <bits/stdc++.h> using namespace std; string s, s1; long long a, b, n; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> s; cin >> s1; n = (long long)s.size(); for (long long i = 0; i < n; i += 2) { if (s[i] == s1[i]) continue; if (s[i] == '8') { if (s1[i] == '(') b++; else a++; } if (s[i] == '(') { if (s1[i] == '[') b++; else a++; } if (s[i] == '[') { if (s1[i] == '8') b++; else a++; } } if (a == b) { cout << "TIE"; return 0; } if (a > b) cout << "TEAM 1 WINS"; else cout << "TEAM 2 WINS"; return 0; }
7
CPP
""" Codeforces April Fools Contest 2014 Problem A Author : chaotic_iak Language: Python 3.3.4 """ class InputHandlerObject(object): inputs = [] def getInput(self, n = 0): res = "" inputs = self.inputs if not inputs: inputs.extend(input().split(" ")) if n == 0: res = inputs[:] inputs[:] = [] while n > len(inputs): inputs.extend(input().split(" ")) if n > 0: res = inputs[:n] inputs[:n] = [] return res InputHandler = InputHandlerObject() g = InputHandler.getInput ############################## SOLUTION ############################## plays = ["()", "[]", "8<"] x = input() y = input() w = 0 for i in range(0, len(x)//2): m = plays.index(x[2*i:2*i+2]) n = plays.index(y[2*i:2*i+2]) if m == n+1 or m == n-2: w += 1 if m == n+2 or m == n-1: w -= 1 if w > 0: print("TEAM 1 WINS") if w == 0: print("TIE") if w < 0: print("TEAM 2 WINS")
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { string s1, s2, ds1, ds2; int b; b = 0; cin >> s1; cin >> s2; for (int i = 0; i < s1.length(); i += 2) { ds1 = ""; ds2 = ""; ds1 += s1[i]; ds1 += s1[i + 1]; ds2 += s2[i]; ds2 += s2[i + 1]; if (ds1 == "8<" && ds2 == "[]") b++; else if (ds1 == "8<" && ds2 == "()") b--; else if (ds1 == "[]" && ds2 == "()") b++; else if (ds1 == "[]" && ds2 == "8<") b--; else if (ds1 == "()" && ds2 == "8<") b++; else if (ds1 == "()" && ds2 == "[]") b--; } if (b > 0) cout << "TEAM 1 WINS"; else if (b < 0) cout << "TEAM 2 WINS"; else cout << "TIE"; return 0; }
7
CPP
#include <bits/stdc++.h> using namespace std; const int N = 5e5; const long double EPS = (long double)1e-10; int main() { ios_base::sync_with_stdio(0); string s, t; cin >> s >> t; int a = 0, b = 0; for (int i = 0; i < s.size(); i += 2) { if (s[i] != t[i]) { if ((s[i] == '[' && t[i] == '(') || (s[i] == '8' && t[i] == '[') || (s[i] == '(' && t[i] == '8')) a++; else b++; } } if (a > b) cout << "TEAM 1 WINS"; else if (a < b) cout << "TEAM 2 WINS"; else cout << "TIE"; return 0; }
7
CPP
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int c1 = 0, c2 = 0; string s1, s2; cin >> s1 >> s2; for (int i = 0; i < s1.size(); i += 2) { if (s1[i] == '[' && s2[i] == '8') { c2++; continue; } if (s1[i] == '[' && s2[i] == '(') { c1++; continue; } if (s1[i] == '8' && s2[i] == '(') { c2++; continue; } if (s1[i] == '8' && s2[i] == '[') { c1++; continue; } if (s1[i] == '(' && s2[i] == '[') { c2++; continue; } if (s1[i] == '(' && s2[i] == '8') { c1++; continue; } } if (c1 > c2) { cout << "TEAM 1 WINS"; } if (c2 > c1) { cout << "TEAM 2 WINS"; } else if (c1 == c2) { cout << "TIE"; } return 0; }
7
CPP
#include <bits/stdc++.h> using namespace std; string s, t; int a, b; bool bate(string a, string b) { if (a == "8<") return b == "[]"; else if (a == "[]") return b == "()"; else return b == "8<"; } int main() { cin >> s >> t; for (int i = 0; i + 1 < s.size(); i += 2) { a += bate(s.substr(i, 2), t.substr(i, 2)); b += bate(t.substr(i, 2), s.substr(i, 2)); } if (a == b) cout << "TIE"; else if (a > b) cout << "TEAM 1 WINS"; else if (a < b) cout << "TEAM 2 WINS"; return 0; }
7
CPP
#include <bits/stdc++.h> using namespace std; int main() { string x, y; cin >> x >> y; int n1 = 0, n2 = 0, n3; for (int i = 0; i < x.size(); i += 2) { if (x[i] == '[' && y[i] == '(') n1++; else if (x[i] == '[' && y[i] == '8') n2++; else if (x[i] == '(' && y[i] == '[') n2++; else if (x[i] == '(' && y[i] == '8') n1++; else if (x[i] == '8' && y[i] == '[') n1++; else if (x[i] == '8' && y[i] == '(') n2++; } if (n1 > n2) cout << "TEAM 1 WINS"; else if (n2 > n1) cout << "TEAM 2 WINS"; else cout << "TIE"; return 0; }
7
CPP
#include <bits/stdc++.h> using namespace std; char kk[20] = "8()[]<"; int main() { ios::sync_with_stdio(false); char a[100], b[100]; while (cin >> a >> b) { int n = strlen(a); int key = 0; for (int i = 0; i < n; i++) { if (a[i] == '8' && b[i] == '[' || (a[i] == '<' && b[i] == ']')) key++; if (a[i] == '[' && b[i] == '8' || (a[i] == ']' && b[i] == '<')) key--; if (a[i] == '[' && b[i] == '(' || (a[i] == ']' && b[i] == ')')) key++; if (a[i] == ')' && b[i] == ']' || (a[i] == '(' && b[i] == '[')) key--; if (a[i] == '8' && b[i] == '(' || (a[i] == '<' && b[i] == ')')) key--; if (a[i] == '(' && b[i] == '8' || (a[i] == ')' && b[i] == '<')) key++; } memset(a, '\0', sizeof(a)); memset(b, '\0', sizeof(b)); if (key == 0) cout << "TIE" << endl; else if (key < 0) cout << "TEAM 2 WINS" << endl; else if (key > 0) cout << "TEAM 1 WINS" << endl; } return 0; }
7
CPP
#include <bits/stdc++.h> using namespace std; inline long long IN() { long long x = 0; int ch = getchar(), f = 1; while (!isdigit(ch) && (ch != '-') && (ch != EOF)) ch = getchar(); if (ch == '-') { f = -1; ch = getchar(); } while (isdigit(ch)) { x = (x << 1) + (x << 3) + ch - '0'; ch = getchar(); } return x * f; } inline void OUT(long long x) { if (x < 0) putchar('-'), x = -x; if (x >= 10) OUT(x / 10), putchar(x % 10 + '0'); else putchar(x + '0'); } char a[25], b[25]; int Ans, la, lb; int main() { scanf("%s", &a); scanf("%s", &b); int len = strlen(a); for (int i = 0; i < len; i += 2) { if (a[i] == '8') la = 0; if (a[i] == '(') la = 1; if (a[i] == '[') la = 2; if (b[i] == '8') lb = 0; if (b[i] == '(') lb = 1; if (b[i] == '[') lb = 2; Ans += ((la - lb + 1) % 3 - 2) % 3 + 1; } if (Ans > 0) puts("TEAM 1 WINS"); if (Ans < 0) puts("TEAM 2 WINS"); if (Ans == 0) puts("TIE"); }
7
CPP
#include <bits/stdc++.h> using namespace std; int main() { string s1, s2; int re = 0; cin >> s1; cin >> s2; for (int i = 0; i < s1.size(); i++) { if (s1[i] == '(') { if (s2[i] == '8') re++; if (s2[i] == '[') re--; } if (s1[i] == '8') { if (s2[i] == '[') re++; if (s2[i] == '(') re--; } if (s1[i] == '[') { if (s2[i] == '(') re++; if (s2[i] == '8') re--; } } if (re > 0) cout << "TEAM 1 WINS"; else if (re < 0) cout << "TEAM 2 WINS"; else cout << "TIE"; }
7
CPP
#include <bits/stdc++.h> using namespace std; string s1, s2; int a1 = 0, a2 = 0; int main() { cin >> s1 >> s2; for (int i = 0; i < s1.size(); i += 2) { if (s1[i] == s2[i]) continue; if ((s1[i] == '(' && s2[i] == '8') || (s1[i] == '8' && s2[i] == '[') || (s1[i] == '[' && s2[i] == '(')) a1++; else a2++; } if (a1 > a2) printf("TEAM 1 WINS"); else if (a1 < a2) printf("TEAM 2 WINS"); else printf("TIE"); return 0; }
7
CPP
#include <bits/stdc++.h> using namespace std; char check(char a, char b) { if (a == '(' && b == ')') return 'r'; else if (a == '[' && b == ']') return 'p'; else return 's'; } int win(char a, char b) { if (a == 'r' && b == 'p') return -1; if (a == 'p' && b == 's') return -1; if (a == 's' && b == 'r') return -1; if (a != b) return 1; return 0; } int main() { string s1, s2; cin >> s1 >> s2; int len = s1.length(); int t1 = 0, t2 = 0; for (int i = 0; i < len; i += 2) { char c1 = check(s1[i], s1[i + 1]); char c2 = check(s2[i], s2[i + 1]); int winner = win(c1, c2); if (winner == -1) t2++; else if (winner == 1) t1++; } if (t1 == t2) cout << "TIE\n"; else if (t1 > t2) cout << "TEAM 1 WINS\n"; else cout << "TEAM 2 WINS\n"; return 0; }
7
CPP
cnt=0 t1=input() t2=input() for i in range(0,len(t1),2): p1=t1[i:i+2] p2=t2[i:i+2] if(p1=="8<"): if(p2=="[]"): cnt+=1 elif(p2=="()"): cnt-=1 elif(p1=="[]"): if(p2=="()"): cnt+=1 elif(p2=="8<"): cnt-=1 else: if(p2=="8<"): cnt+=1 elif(p2=="[]"): cnt-=1 if(cnt==0): print("TIE") elif(cnt>0): print("TEAM 1 WINS") else: print("TEAM 2 WINS")
7
PYTHON3
#include <bits/stdc++.h> using namespace std; string s1, s2; int a1 = 0, a2 = 0; int main() { cin >> s1 >> s2; for (int i = 0; i < s1.size(); i += 2) { if (s1[i] == s2[i]) continue; if ((s1[i] == '(' && s2[i] == '8') || (s1[i] == '8' && s2[i] == '[') || (s1[i] == '[' && s2[i] == '(')) a1++; else a2++; } if (a1 > a2) printf("TEAM 1 WINS"); else if (a1 < a2) printf("TEAM 2 WINS"); else printf("TIE"); return 0; }
7
CPP
def ii(): return int(input()) def fi(): return float(input()) def si(): return input() def mi(): return map(int,input().split()) def li(): return list(mi()) s=si() t=si() c=d=0 for i in range(0,len(s)-1,2): if s[i]=="8": if t[i]=="[": c+=1 elif t[i]=="(": d+=1 elif s[i]=="(": if t[i]=="8": c+=1 elif t[i]=="[": d+=1 else: if t[i]=="(": c+=1 elif t[i]=="8": d+=1 if c>d: print("TEAM 1 WINS") elif d>c: print("TEAM 2 WINS") else: print("TIE")
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { string a, b; cin >> a >> b; int pointsA = 0, pointsB = 0, s = b.size(); for (int i = 0; i < s; i += 2) { if ((a[i] == '[' && b[i] == '(') || (a[i] == '8' && b[i] == '[') || (a[i] == '(' && b[i] == '8')) { pointsA++; } else if ((a[i] == '[' && b[i] == '8') || (a[i] == '8' && b[i] == '(') || (a[i] == '(' && b[i] == '[')) { pointsB++; } } if (pointsA > pointsB) { cout << "TEAM 1 WINS"; } else if (pointsB > pointsA) { cout << "TEAM 2 WINS"; } else { cout << "TIE"; } }
7
CPP
#include <bits/stdc++.h> using namespace std; int main() { int cont1 = 0; int cont2 = 0; string a, b; cin >> a >> b; for (int i = 0; i < a.size(); i += 2) { if (a[i] == '[' && b[i] == '(') cont1++; if (a[i] == '8' && b[i] == '[') cont1++; if (a[i] == '(' && b[i] == '8') cont1++; if (b[i] == '[' && a[i] == '(') cont2++; if (b[i] == '8' && a[i] == '[') cont2++; if (b[i] == '(' && a[i] == '8') cont2++; } if (cont1 > cont2) { printf("TEAM 1 WINS\n"); } if (cont2 > cont1) { printf("TEAM 2 WINS\n"); } if (cont1 == cont2) { printf("TIE\n"); } return 0; }
7
CPP
a = input() b = input() pa = 0 pb = 0 wins = {'8': '[', '[': '(', '(': '8'} for i in range(int(len(a)/2)): if b[2*i] == wins[a[2*i]]: pa += 1 elif a[2*i] != b[2*i]: pb += 1 if pa > pb: print('TEAM 1 WINS'); elif pa < pb: print('TEAM 2 WINS'); else: print('TIE');
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main(void) { char act1[21], act2[21]; int score1 = 0, score2 = 0; scanf("%s %s", act1, act2); for (int i = 0; act1[i]; i += 2) { if (act1[i] == act2[i]) continue; switch (act1[i]) { case '(': { switch (act2[i]) { case '[': { score2++; break; } case '8': { score1++; break; } } break; } case '8': { switch (act2[i]) { case '(': { score2++; break; } case '[': { score1++; break; } } break; } case '[': { switch (act2[i]) { case '8': { score2++; break; } case '(': { score1++; break; } } break; } } } if (score1 > score2) puts("TEAM 1 WINS"); else if (score1 < score2) puts("TEAM 2 WINS"); else puts("TIE"); return 0; }
7
CPP
#include <bits/stdc++.h> using namespace std; int change(char p) { switch (p) { case '[': return 2; case '8': return 1; case '(': return 0; } return 0; } int main() { string P, Q; cin >> P >> Q; int ans = 0; for (int i = 0; i < P.size(); i += 2) { int a, b; a = change(P[i]); b = change(Q[i]); if (a == b) continue; if (a == (b + 1) % 3) --ans; else ++ans; } if (ans > 0) cout << "TEAM 1 WINS" << endl; if (ans < 0) cout << "TEAM 2 WINS" << endl; if (ans == 0) cout << "TIE" << endl; return 0; }
7
CPP
#include <bits/stdc++.h> char s1[25], s2[25]; int main() { gets(s1); gets(s2); int a1 = 0, a2 = 0; int len = strlen(s1); for (int i = 0; i < len; i += 2) if (s1[i] != s2[i]) { if (s1[i] == '8' && s2[i] == '[') a1++; if (s1[i] == '8' && s2[i] == '(') a2++; if (s1[i] == '[' && s2[i] == '8') a2++; if (s1[i] == '[' && s2[i] == '(') a1++; if (s1[i] == '(' && s2[i] == '8') a1++; if (s1[i] == '(' && s2[i] == '[') a2++; } if (a1 > a2) puts("TEAM 1 WINS"); if (a1 == a2) puts("TIE"); if (a1 < a2) puts("TEAM 2 WINS"); return 0; }
7
CPP
#include <bits/stdc++.h> using namespace std; char str[2][32]; int get(const char ch) { switch (ch) { case '(': return 0; case '8': return 1; case '[': return 2; return -1; } } int cmp(int a, int b) { if (a == b) return 0; if ((a + 1) % 3 == b) return 1; return -1; } int check(const char *a, const char *b) { int i, l = strlen(a), ret = 0; for (i = 0; i < l; i += 2) ret += cmp(get(a[i]), get(b[i])); return ret; } int main() { int ans; while (~scanf("%s%s", str[0], str[1])) { ans = check(str[0], str[1]); if (ans == 0) printf("TIE\n"); else if (ans > 0) printf("TEAM 1 WINS\n"); else printf("TEAM 2 WINS\n"); } return 0; }
7
CPP
#include <bits/stdc++.h> using namespace std; int GCD(int a, int b) { if (b == 0) return a; return (a % b == 0 ? b : GCD(b, a % b)); } long long int POW(long long int base, long long int exp) { long long int val; val = 1; while (exp > 0) { if (exp % 2 == 1) { val = (val * base) % 1000000007; } base = (base * base) % 1000000007; exp = exp / 2; } return val; } int main() { int i, p; char s1[25], s2[25]; scanf("%s", s1); scanf("%s", s2); p = 0; for (i = 0; s1[i] != '\0'; i += 2) { if (s1[i] == '8') { if (s2[i] == '[') { p++; } else if (s2[i] == '(') { p--; } } else if (s1[i] == '(') { if (s2[i] == '8') { p++; } else if (s2[i] == '[') { p--; } } else if (s1[i] == '[') { if (s2[i] == '(') { p++; } else if (s2[i] == '8') { p--; } } } if (p > 0) { printf("TEAM 1 WINS\n"); } else if (p < 0) { printf("TEAM 2 WINS\n"); } else { printf("TIE\n"); } return 0; }
7
CPP
#include <bits/stdc++.h> using namespace std; int main() { string t1; string t2; cin >> t1 >> t2; int len = t1.length(); int t1Wins = 0; int t2Wins = 0; int turn = 0; while (turn < len) { if (t1[turn] == t2[turn]) { } else if (t1[turn] == '[' && t2[turn] == '8') { ++t2Wins; } else if (t1[turn] == '[' && t2[turn] == '(') { ++t1Wins; } else if (t1[turn] == '(' && t2[turn] == '8') { ++t1Wins; } else if (t1[turn] == '(' && t2[turn] == '[') { ++t2Wins; } else if (t1[turn] == '8' && t2[turn] == '[') { ++t1Wins; } else if (t1[turn] == '8' && t2[turn] == '(') { ++t2Wins; } turn = turn + 2; } if (t1Wins > t2Wins) { cout << "TEAM 1 WINS" << endl; } else if (t2Wins > t1Wins) { cout << "TEAM 2 WINS" << endl; } else { cout << "TIE" << endl; } return 0; }
7
CPP
#include <bits/stdc++.h> using namespace std; const double pi = acos(-1); const double eps = 1e-10; const int inf = 0x3f3f3f3f; const long long infLL = 0x3f3f3f3f3f3f3f3fLL; int main() { string a, b; int x = 0, y = 0; cin >> a >> b; for (int i = 0; i < a.length(); i += 2) { if (a[i] == b[i]) continue; if (a[i] == '8') { if (b[i] == '(') ++y; else ++x; } if (a[i] == '(') { if (b[i] == '8') ++x; else ++y; } if (a[i] == '[') { if (b[i] == '8') ++y; else ++x; } } if (x == y) cout << "TIE" << endl; else if (x > y) cout << "TEAM 1 WINS" << endl; else cout << "TEAM 2 WINS" << endl; return 0; }
7
CPP
s1 = input() s2 = input() n = len(s1) bal = 0 for i in range(0, n, 2): if s1[i] == '8' and s2[i] == '[': bal += 1 if s1[i] == '8' and s2[i] == '(': bal -= 1 if s1[i] == '(' and s2[i] == '[': bal -= 1 if s1[i] == '(' and s2[i] == '8': bal += 1 if s1[i] == '[' and s2[i] == '(': bal += 1 if s1[i] == '[' and s2[i] == '8': bal -= 1 if bal == 0: print('TIE') elif bal > 0: print('TEAM 1 WINS') else: print('TEAM 2 WINS')
7
PYTHON3
#include <bits/stdc++.h> using namespace std; const int MAX = 100; char A[MAX], B[MAX]; int main() { scanf("%s", (A)); scanf("%s", (B)); int N = int(strlen(A)), M = int(strlen(B)); int c1 = 0, c2 = 0; for (int i = (0); i < (N); i += 2) { if (A[i] == '8' && B[i] == '[') c1++; if (A[i] == '[' && B[i] == '(') c1++; if (A[i] == '(' && B[i] == '8') c1++; if (B[i] == '8' && A[i] == '[') c2++; if (B[i] == '[' && A[i] == '(') c2++; if (B[i] == '(' && A[i] == '8') c2++; } if (c1 == c2) { printf("TIE"); } else if (c1 < c2) { printf("TEAM 2 WINS"); } else { printf("TEAM 1 WINS"); } return 0; }
7
CPP
#include <bits/stdc++.h> using namespace std; int main() { string s1, s2; cin >> s1 >> s2; int n = s1.length(); int res = 0; for (int i = 0; i < n; i += 2) { string c1 = "", c2 = ""; c1 += s1[i]; c1 += s1[i + 1]; c2 += s2[i]; c2 += s2[i + 1]; if (c1 == "8<") { if (c2 == "[]") res++; else if (c2 == "()") res--; } else if (c1 == "[]") { if (c2 == "8<") res--; else if (c2 == "()") res++; } else { if (c2 == "[]") res--; else if (c2 == "8<") res++; } } if (res == 0) cout << "TIE"; else if (res > 0) cout << "TEAM 1 WINS"; else cout << "TEAM 2 WINS"; return 0; }
7
CPP
#include <bits/stdc++.h> using namespace std; int main() { char a[1005], b[1005]; int x, y, i, l; while (scanf("%s%s", a, b) != EOF) { l = strlen(a); x = 0; y = 0; for (i = 0; i < l; i = i + 2) { if (a[i] == b[i]) { continue; } else { if ((a[i] == '8' && b[i] == '[') || (a[i] == '[' && b[i] == '(') || (a[i] == '(' && b[i] == '8')) { x++; } else { y++; } } } if (x == y) printf("TIE\n"); else if (x > y) printf("TEAM 1 WINS\n"); else printf("TEAM 2 WINS\n"); } return 0; }
7
CPP
#include <bits/stdc++.h> using namespace std; int w1, w2; string s1, s2; int main() { cin >> s1 >> s2; for (int i = 0; i < s1.size(); i += 2) { int a1, a2; if (s1[i] == '8' && s1[i + 1] == '<') a1 = 1; else if (s1[i] == '[' && s1[i + 1] == ']') a1 = 2; else a1 = 3; if (s2[i] == '8' && s2[i + 1] == '<') a2 = 1; else if (s2[i] == '[' && s2[i + 1] == ']') a2 = 2; else a2 = 3; if (a1 == a2 - 1 || a1 == 3 && a2 == 1) w1++; else if (a2 == a1 - 1 || a2 == 3 && a1 == 1) w2++; } if (w1 > w2) cout << "TEAM 1 WINS"; else if (w1 < w2) cout << "TEAM 2 WINS"; else cout << "TIE"; return 0; }
7
CPP
#include <bits/stdc++.h> using namespace std; int main() { char key[] = "(8["; char fir[100], sec[100]; int i, len, a, b, c; scanf("%s%s", fir, sec); len = strlen(fir); c = 0; for (i = 0; i < len; i += 2) { a = strchr(key, fir[i]) - key; b = strchr(key, sec[i]) - key; if (a == b) continue; if ((a + 1) % 3 == b) c++; else c--; } if (c > 0) puts("TEAM 1 WINS"); else if (c < 0) puts("TEAM 2 WINS"); else puts("TIE"); return 0; }
7
CPP
#include <bits/stdc++.h> char a[99]; char b[99]; int n; int c, d; int get(char p, char q, char r, char s) { if (p == r) return 0; if (p == '(') { if (r == '[') return -1; return 1; } else if (p == '[') { if (r == '(') return 1; return -1; } else { if (r == '(') return -1; return 1; } } int main() { int i, j; scanf("%s %s", a, b); n = strlen(a); for (i = 0; i < n; i += 2) { j = get(a[i], a[i + 1], b[i], b[i + 1]); if (j == 1) c++; else if (j == -1) c--; } if (c == 0) printf("TIE\n"); else if (c > 0) printf("TEAM 1 WINS\n"); else printf("TEAM 2 WINS\n"); }
7
CPP
#include <bits/stdc++.h> using namespace std; int isWin(string a, string b) { if ((a == "8<" && b == "[]") || (a == "()" && b == "8<") || (a == "[]" && b == "()")) return 0; else if ((b == "8<" && a == "[]") || (b == "()" && a == "8<") || (b == "[]" && a == "()")) return 1; else return 2; } int main() { string str1, str2; cin >> str1 >> str2; int pts1 = 0, pts2 = 0; for (int i = 0; i < str1.size(); i += 2) { string move1, move2; move1 += str1[i]; move1 += str1[i + 1]; move2 += str2[i]; move2 += str2[i + 1]; if (isWin(move1, move2) == 0) pts1++; else if (isWin(move1, move2) == 1) pts2++; else { pts1++; pts2++; } } if (pts1 > pts2) cout << "TEAM 1 WINS"; else if (pts2 > pts1) cout << "TEAM 2 WINS"; else cout << "TIE"; cin.ignore(); cin.get(); return 0; }
7
CPP
#include <bits/stdc++.h> using namespace std; char s[50], c[50]; int t1 = 0, t2 = 0; int main() { cin >> s >> c; for (int i = 0; i < strlen(s); i += 2) { if ((s[i] == '8' && c[i] == '[') || (s[i] == '[' && c[i] == '(') || (s[i] == '(' && c[i] == '8')) t1++; else if (s[i] != c[i]) t2++; } if (t1 > t2) cout << "TEAM 1 WINS"; else if (t2 > t1) cout << "TEAM 2 WINS"; else cout << "TIE"; }
7
CPP
a = input() b = input() a = [ a[i:i+2] for i in range(0, len(a), 2) ] b = [ b[i:i+2] for i in range(0, len(b), 2) ] def win(x, y): if x == '8<': return y == '[]' if x == '[]': return y == '()' if x == '()': return y == '8<' return False # print(a) # print(b) ac = sum( win(x,y) for x,y in zip(a,b) ) bc = sum( win(x,y) for x,y in zip(b,a) ) if ac == bc: print('TIE') elif ac > bc: print('TEAM 1 WINS') else: print('TEAM 2 WINS')
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { string s, t; while (cin >> s >> t) { int cont1 = 0, cont2 = 0; for (int i = 0; i < s.size(); i += 2) { cont1 += (s[i] == '(' && t[i] == '8') || (s[i] == '8' && t[i] == '[') || (s[i] == '[' && t[i] == '('); cont2 += (t[i] == '(' && s[i] == '8') || (t[i] == '8' && s[i] == '[') || (t[i] == '[' && s[i] == '('); } printf("%s\n", cont1 < cont2 ? "TEAM 2 WINS" : cont1 > cont2 ? "TEAM 1 WINS" : "TIE"); } return 0; }
7
CPP
#include <bits/stdc++.h> using namespace std; int main() { string s1, s2, sub1, sub2; int res = 0; cin >> s1 >> s2; int i; for (i = 0; i < s1.length() - 1; i += 2) { sub1 = s1.substr(i, 2); sub2 = s2.substr(i, 2); if (sub1 == "8<" && sub2 == "[]") res++; if (sub1 == "8<" && sub2 == "()") res--; if (sub1 == "[]" && sub2 == "8<") res--; if (sub1 == "[]" && sub2 == "()") res++; if (sub1 == "()" && sub2 == "8<") res++; if (sub1 == "()" && sub2 == "[]") res--; } if (res > 0) cout << "TEAM 1 WINS"; if (res == 0) cout << "TIE"; if (res < 0) cout << "TEAM 2 WINS"; return 0; }
7
CPP
#include <bits/stdc++.h> char a[25], b[25]; int main() { int i, A = 0, B = 0; scanf("%s%s", a, b); for (i = 0; i < strlen(a); i = i + 2) { if (a[i] == '8' && b[i] == '[') A++; if (a[i] == '[' && b[i] == '8') B++; if (a[i] == '[' && b[i] == '(') A++; if (a[i] == '(' && b[i] == '[') B++; if (a[i] == '(' && b[i] == '8') A++; if (a[i] == '8' && b[i] == '(') B++; } if (A > B) printf("TEAM 1 WINS\n"); else if (B > A) printf("TEAM 2 WINS\n"); else printf("TIE\n"); return 0; }
7
CPP
team1=input() score1=0 team2=input() score2=0 for i in range(len(team1)): if team1[i]=='[' and team2[i]=='8': score2+=1 if team1[i]=='[' and team2[i]=='(': score1+=1 if team1[i]=='8' and team2[i]=='[': score1+=1 if team1[i]=='8' and team2[i]=='(': score2+=1 if team1[i]=='(' and team2[i]=='8': score1+=1 if team1[i]=='(' and team2[i]=='[': score2+=1 if score1>score2: print("TEAM 1 WINS") elif score2>score1: print("TEAM 2 WINS") else: print("TIE")
7
PYTHON3
#include <bits/stdc++.h> using namespace std; const int N = 5e6 + 5; const long long inf = 1791791791; const long long mod = 1e9 + 7; int main() { string a, b; cin >> a >> b; int p = 0; for (int i = 0; i < a.size(); i += 2) { if (a[i] == '8') { if (b[i] == '[') p++; if (b[i] == '(') p--; } else if (a[i] == '[') { if (b[i] == '(') p++; if (b[i] == '8') p--; } else { if (b[i] == '8') p++; if (b[i] == '[') p--; } } if (p == 0) printf("TIE\n"); else if (p > 0) printf("TEAM 1 WINS\n"); else printf("TEAM 2 WINS\n"); return 0; }
7
CPP
#include <bits/stdc++.h> using namespace std; int read(int a[50]) { int i; char s[50]; gets(s); for (i = 0; s[i]; i += 2) { if (s[i] == '[') a[i >> 1] = 0; else if (s[i] == '8') a[i >> 1] = 1; else if (s[i] == '(') a[i >> 1] = 2; } return i >> 1; } int main() { int n, a[50], b[50]; n = read(a); read(b); int score = 0; for (int i = 0; i < n; ++i) { if (a[i] != b[i]) { if ((a[i] + 1) % 3 == b[i]) --score; else ++score; } } if (score > 0) printf("TEAM 1 WINS"); else if (score < 0) printf("TEAM 2 WINS"); else printf("TIE"); return 0; }
7
CPP
#include <bits/stdc++.h> using namespace std; int main() { string a, b; cin >> a; cin >> b; int cnt1 = 0, cnt2 = 0; for (int i = 0; i < a.size(); i += 2) { int x, y; if (a[i] == '8') x = 1; else if (a[i] == '(') x = 0; else if (a[i] == '[') x = 2; if (b[i] == '8') y = 1; else if (b[i] == '(') y = 0; else if (b[i] == '[') y = 2; if (x == 0) { if (y == 1) cnt1++; else if (y == 2) cnt2++; } else if (x == 1) { if (y == 0) cnt2++; else if (y == 2) cnt1++; } else if (x == 2) { if (y == 0) cnt1++; else if (y == 1) cnt2++; } } if (cnt1 == cnt2) cout << "TIE"; else cout << (cnt1 > cnt2 ? "TEAM 1 WINS" : "TEAM 2 WINS"); }
7
CPP
#include <bits/stdc++.h> using namespace std; char v[] = {'8', '[', '('}; string s1, s2; int f(char c) { for (int i = 0; i < 3; ++i) { if (c == v[i]) return i; } } int main() { cin >> s1 >> s2; int points = 0; for (int i = 0; i < (s1.size() >> 1); ++i) { int op1 = f(s1[i * 2]), op2 = f(s2[i * 2]); int dif = (op1 - op2); if (dif < 0) dif += 3; if (dif == 1) points++; else if (dif == 2) points--; } if (points > 0) { cout << "TEAM 2 WINS\n"; } else if (points < 0) { cout << "TEAM 1 WINS\n"; } else cout << "TIE\n"; return 0; }
7
CPP
# Made By Mostafa_Khaled bot = True t=0 a,b,c=input(),input(),'8([' for i in range(0,len(a),2): k=c.index(a[i]) t+=1 if b[i]==c[k-1]else 0 if b[i]==c[k]else -1 print("TEAM %d WINS"%(1 if t>0 else 2)if t else "TIE") # Made By Mostafa_Khaled
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main(void) { string a, b; cin >> a >> b; int balance = 0; for (int i = 0; i < a.length(); i += 2) { if (a[i] == '[' && a[i + 1] == ']') { if (b[i] == '(' && b[i + 1] == ')') { balance--; } if (b[i] == '8' && b[i + 1] == '<') { balance++; } } if (a[i] == '(' && a[i + 1] == ')') { if (b[i] == '8' && b[i + 1] == '<') { balance--; } if (b[i] == '[' && b[i + 1] == ']') { balance++; } } if (a[i] == '8' && a[i + 1] == '<') { if (b[i] == '[' && b[i + 1] == ']') { balance--; } if (b[i] == '(' && b[i + 1] == ')') { balance++; } } } if (balance < 0) cout << "TEAM 1 WINS"; else if (balance > 0) cout << "TEAM 2 WINS"; else cout << "TIE"; return 0; }
7
CPP
import sys def solve(): first = input() second = input() res = 0 for i in range(0, len(first), 2): res += helper(first[i:i+2], second[i:i+2]) return "TIE" if res == 0 else ("TEAM 1 WINS" if res > 0 else "TEAM 2 WINS") def helper(f, s): if f == s: return 0 if f == "[]": if s == "()": return 1 return -1 if f == "()": if s == "[]": return -1 return 1 if s == "[]": return 1 return -1 if sys.hexversion == 50594544 : sys.stdin = open("test.txt") print(solve())
7
PYTHON3
#include <bits/stdc++.h> using namespace std; char s[2][100]; int fun(char a, char b) { if (a == '8') { if (b == '[') return 1; else if (b == '(') return -1; else return 0; } if (a == '[') { if (b == '8') return -1; else if (b == '(') return 1; else return 0; } if (a == '(') { if (b == '[') return -1; else if (b == '8') return 1; else return 0; } } int main() { while (cin >> s[0] >> s[1]) { int sum1 = 0, sum2 = 0; for (int i = 0; s[0][i]; i += 2) sum1 += fun(s[0][i], s[1][i]); if (sum1 > 0) printf("TEAM 1 WINS\n"); else if (sum1 < 0) printf("TEAM 2 WINS\n"); else printf("TIE\n"); } return 0; }
7
CPP
#include <bits/stdc++.h> using namespace std; int main() { string x, s, sub1, sub2, R = "()", S = "8<", P = "[]"; int count1 = 0, count2 = 0, a, b; cin >> x; cin >> s; for (int i = 0; i < x.length(); i += 2) { sub1 = x.substr(i, 2); sub2 = s.substr(i, 2); if ((sub1 == P) && (sub2 == R)) count1++; else if ((sub1 == R) && (sub2 == S)) count1++; else if ((sub1 == S) && (sub2 == P)) count1++; else if ((sub1 == R) && (sub2 == P)) count2++; else if ((sub1 == S) && (sub2 == R)) count2++; else if ((sub1 == P) && (sub2 == S)) count2++; } if (count1 > count2) cout << "TEAM 1 WINS"; else if (count2 > count1) cout << "TEAM 2 WINS"; else cout << "TIE"; return 0; }
7
CPP
#include <bits/stdc++.h> int main() { char a[100], b[100]; int l, i, count1, count2; while (scanf("%s %s", a, b) != EOF) { count1 = 0, count2 = 0; l = strlen(a); for (i = 0; i < l; i += 2) { if (a[i] == '8' && b[i] == '8') ; else if (a[i] == '8' && b[i] == '[') count1++; else if (a[i] == '8' && b[i] == '(') count2++; else if (a[i] == '(' && b[i] == '8') count1++; else if (a[i] == '(' && b[i] == '(') ; else if (a[i] == '(' && b[i] == '[') count2++; else if (a[i] == '[' && b[i] == '(') count1++; else if (a[i] == '[' && b[i] == '8') count2++; else if (a[i] == '[' && b[i] == '[') ; } if (count1 == count2) printf("TIE\n"); else if (count1 < count2) printf("TEAM 2 WINS\n"); else printf("TEAM 1 WINS\n"); } return 0; }
7
CPP
D = { "8<": "[]", "[]": "()", "()": "8<" } cnt = 0 s1, s2 = input(), input() for i in range(0, len(s1), 2): t1, t2 = s1[i:i+2], s2[i:i+2] if D[t1] == t2: cnt += 1 elif D[t2] == t1: cnt -= 1 if cnt > 0: print("TEAM 1 WINS") elif cnt < 0: print("TEAM 2 WINS") else: print("TIE")
7
PYTHON3
#include <bits/stdc++.h> using namespace std; string s, s1; int a[500], i, j, k, l, m, n; int main() { cin >> s; cin >> s1; for (int i = 0; i < s.size(); i += 2) { if (s[i] == '8' && s[i + 1] == '<') if (s1[i] == '(' && s1[i + 1] == ')') k--; if (s[i] == '8' && s[i + 1] == '<') if (s1[i] == '[' && s1[i + 1] == ']') k++; if (s[i] == '(' && s[i + 1] == ')') if (s1[i] == '8' && s1[i + 1] == '<') k++; if (s[i] == '(' && s[i + 1] == ')') if (s1[i] == '[' && s1[i + 1] == ']') k--; if (s[i] == '[' && s[i + 1] == ']') if (s1[i] == '8' && s1[i + 1] == '<') k--; if (s[i] == '[' && s[i + 1] == ']') if (s1[i] == '(' && s1[i + 1] == ')') k++; } if (k > 0) cout << "TEAM 1 WINS" << endl; else if (k < 0) cout << "TEAM 2 WINS" << endl; else cout << "TIE" << endl; }
7
CPP
#!/bin/python team1 = input().replace('[', '7').replace('(', '6') team2 = input().replace('[', '7').replace('(', '6') s = 0 for i in range(0, len(team1), 2): if team1[i] > team2[i]: s += 1 elif team1[i] < team2[i]: s -= 1 if team1[i] == '8' and team2[i] == '6': s -= 2 if team1[i] == '6' and team2[i] == '8': s += 2 if s > 0: print("TEAM 1 WINS") elif s < 0: print("TEAM 2 WINS") else: print("TIE")
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { string t1, t2; cin >> t1 >> t2; int _1 = 0, _2 = 0; for (int i = 0; i < t1.size(); i += 2) { if (t1[i] == '[') { if (t2[i] == '8') _2++; else if (t2[i] == '(') _1++; } else if (t1[i] == '8') { if (t2[i] == '[') _1++; else if (t2[i] == '(') _2++; } else if (t1[i] == '(') { if (t2[i] == '8') _1++; else if (t2[i] == '[') _2++; } } cout << (_1 > _2 ? "TEAM 1 WINS" : _1 == _2 ? "TIE" : "TEAM 2 WINS") << "\n"; return 0; }
7
CPP
#include <bits/stdc++.h> using namespace std; int main() { char s[25]; char t[25]; scanf("%s", s); scanf("%s", t); int len = strlen(s); int res = 0; for (int i = 0; i < len; i += 2) { if (s[i] == '[') { if (t[i] == '(') { res++; } else if (t[i] == '8') { res--; } } else if (s[i] == '(') { if (t[i] == '[') { res--; } else if (t[i] == '8') { res++; } } else if (s[i] == '8') { if (t[i] == '(') { res--; } else if (t[i] == '[') { res++; } } } if (res > 0) { puts("TEAM 1 WINS"); } else if (res < 0) { puts("TEAM 2 WINS"); } else { puts("TIE"); } return 0; }
7
CPP
s1 = input() s2 = input() win = { '()': '8<', '[]': '()', '8<': '[]' } score = [0, 0] n = len(s1) for i in range(0, n, 2): a = s1[i:i + 2] b = s2[i:i + 2] if a == b: continue if win[a] == b: score[0] += 1 else: score[1] += 1 if score[0] == score[1]: print('TIE') elif score[0] > score[1]: print('TEAM 1 WINS') else: print('TEAM 2 WINS')
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { char ansString[3][20] = {"TEAM 1 WINS", "TEAM 2 WINS", "TIE"}; char ch1[25], ch2[25]; while (cin >> ch1 >> ch2) { int ans1 = 0; int ans2 = 0; for (int i = 0; ch1[i] != '\0'; i += 2) { if (ch1[i] == ch2[i]) { ++ans1; ++ans2; } else if (ch1[i] == '8' && ch2[i] == '[') ++ans1; else if (ch1[i] == '[' && ch2[i] == '8') ++ans2; else if (ch1[i] == '[' && ch2[i] == '(') ++ans1; else if (ch1[i] == '(' && ch2[i] == '[') ++ans2; else if (ch1[i] == '(' && ch2[i] == '8') ++ans1; else if (ch1[i] == '8' && ch2[i] == '(') ++ans2; } if (ans1 > ans2) cout << ansString[0] << endl; else if (ans1 == ans2) cout << ansString[2] << endl; else cout << ansString[1] << endl; } return 0; }
7
CPP
#include <bits/stdc++.h> using namespace std; int win(char a, char b) { if (a == '8') { if (b == '8') return 0; return (b == '[' ? 1 : -1); } if (a == '[') { if (b == '[') return 0; return (b == '(' ? 1 : -1); } if (a == '(') { if (b == '(') return 0; return (b == '8' ? 1 : -1); } } int main() { string s1, s2; getline(cin, s1); getline(cin, s2); int t = s1.length(); --t; int wn = 0; for (int i = 0; i < t; i += 2) { wn += win(s1[i], s2[i]); } if (wn > 0) cout << "TEAM 1 WINS\n"; else if (wn < 0) cout << "TEAM 2 WINS\n"; else cout << "TIE\n"; }
7
CPP
s1 = input() s2 = input() b = 0 n = len(s1) for i in range(0,n,2): if s1[i] + s1[i+1] == '8<': if s2[i] + s2[i+1] == '[]': b+=1 elif s2[i] + s2[i+1] == '()': b-=1 elif s1[i] + s1[i+1] == '[]': if s2[i] + s2[i+1] == '8<': b-=1 elif s2[i] + s2[i+1] == '()': b+=1 else: if s2[i] + s2[i+1] == '8<': b+=1 elif s2[i] + s2[i+1] == '[]': b-=1 if b > 0: print('TEAM 1 WINS') elif b < 0: print('TEAM 2 WINS') else: print('TIE')
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { string s1, s2; getline(cin, s1); getline(cin, s2); int t1 = 0, t2 = 0; for (int i = 0; i < s1.size(); i += 2) { if (s1[i] == '8') { if (s2[i] == '[') t1++; if (s2[i] == '(') t2++; } if (s1[i] == '(') { if (s2[i] == '8') t1++; if (s2[i] == '[') t2++; } if (s1[i] == '[') { if (s2[i] == '(') t1++; if (s2[i] == '8') t2++; } } if (t1 > t2) cout << "TEAM 1 WINS"; if (t1 < t2) cout << "TEAM 2 WINS"; if (t1 == t2) cout << "TIE"; return 0; }
7
CPP
#include <bits/stdc++.h> using namespace std; int main() { int ans = 0, res = 0; string s, a; cin >> s >> a; for (int i = 0; i < s.size(); i++) { if (s[i] == '(' && a[i] == '8') res++; else if (a[i] == '(' && s[i] == '8') ans++; else if (s[i] == '8' && a[i] == '[') res++; else if (a[i] == '8' && s[i] == '[') ans++; else if (s[i] == '[' && a[i] == '(') res++; else if (a[i] == '[' && s[i] == '(') ans++; } if (res > ans) cout << "TEAM 1 WINS"; else if (ans > res) cout << "TEAM 2 WINS"; else cout << "TIE"; return 0; }
7
CPP
#include <bits/stdc++.h> using namespace std; std::vector<long long> parent; long long find(long long x) { if (parent[x] == x) return x; return find(parent[x]); } void union1(long long a, long long b) { parent[find(b)] = find(a); } int32_t main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); string s1, s2; cin >> s1 >> s2; long long i, one = 0, two = 0; for (i = 0; i < s1.size(); i += 2) { if (s1[i] == '(') { if (s2[i] == '[') two++; else if (s2[i] == '8') one++; } else if (s1[i] == '[') { if (s2[i] == '(') one++; else if (s2[i] == '8') two++; } else { if (s2[i] == '(') two++; else if (s2[i] == '[') one++; } } if (one > two) cout << "TEAM 1 WINS"; else if (two > one) cout << "TEAM 2 WINS"; else cout << "TIE"; return 0; }
7
CPP
#include <bits/stdc++.h> using namespace std; int f(char u, char v) { if (u == '8') return 1; if (u == '(') return 0; return 2; } int main() { string s, t; cin >> s >> t; int s1 = 0, s2 = 0; for (int i = 0; i < s.size(); i += 2) { int num1 = f(s[i], s[i + 1]), num2 = f(t[i], t[i + 1]); if (num1 == num2) continue; else if (num2 == (num1 + 1) % 3) s1++; else s2++; } if (s1 < s2) cout << "TEAM 2 WINS"; else if (s1 > s2) cout << "TEAM 1 WINS"; else cout << "TIE"; }
7
CPP
#include <bits/stdc++.h> using namespace std; int main() { string s1, s2; int p1 = 0, p2 = 0; cin >> s1 >> s2; for (int i = 0; i < (int)s1.size(); i += 2) { if (s1[i] == '(' && s2[i] == '8') p1++; if (s1[i] == '8' && s2[i] == '[') p1++; if (s1[i] == '[' && s2[i] == '(') p1++; if (s2[i] == '(' && s1[i] == '8') p2++; if (s2[i] == '8' && s1[i] == '[') p2++; if (s2[i] == '[' && s1[i] == '(') p2++; } if (p1 > p2) cout << "TEAM 1 WINS" << endl; if (p1 == p2) cout << "TIE" << endl; if (p2 > p1) cout << "TEAM 2 WINS" << endl; return 0; }
7
CPP
a=input() b=input() ans=chk=0 for i in range(1,len(a),2): o,t=a[i-1]+a[i],b[i-1]+b[i] if (o=='8<' and t=='[]') or (o=='[]' and t=='()') or (o=='()' and t=='8<'): ans+=1 elif t!=o: chk+=1 print('TEAM 2 WINS' if chk>ans else 'TEAM 1 WINS' if ans>chk else 'TIE')
7
PYTHON3