#include<stdio.h> #include<string> #include<iostream> #include<algorithm> #include<string.h> #include<vector> #include<queue> #include<set> #include<map> intread(int x = 0, int f = 0, char ch = getchar()) { while (ch < 48or57 < ch) f = ch == 45, ch = getchar(); while(48 <= ch and ch <= 57) x = x * 10 + ch - 48, ch = getchar(); return f ? -x : x; } constint N = 1e6 + 5; int n, a[N];
voidsolve() { std::string a, b, c; int n = read(); std::cin >> a >> b >> c; bool flag = 0; for (int i = 0; i < n; i++) if (a[i] != b[i]) flag |= (a[i] != c[i] && b[i] != c[i]); else flag |= (a[i] != c[i]); puts(flag ? "YES" : "NO"); }
intmain() { #ifndef ONLINE_JUDGE freopen("A.in", "r", stdin); #endif for (int T = read(); T--; solve()); return0; }
#include<stdio.h> #include<string> #include<iostream> #include<algorithm> #include<string.h> #include<vector> #include<queue> #include<set> #include<map> #define int long long intread(int x = 0, int f = 0, char ch = getchar()) { while (ch < 48or57 < ch) f = ch == 45, ch = getchar(); while(48 <= ch and ch <= 57) x = x * 10 + ch - 48, ch = getchar(); return f ? -x : x; } constint N = 3e5 + 5; int n, a[N]; int b[N];
voidsolve() { n = read(); for (int i = 1; i <= n; i++) a[i] = read(); for (int i = 0; i <= n; i++) b[i] = 0; for (int i = 1; i <= n; i++) b[a[i]]++; longlong ans = 0, cnt = 0; for (int i = 0; i <= n; i++) { if (b[i] == 2) ans += cnt; if (b[i] > 2) ans += b[i] * (b[i] - 1) / 2 * cnt + b[i] * (b[i] - 1) * (b[i] - 2) / 6; cnt += b[i]; } printf("%lld\n", ans); }
signedmain() { #ifndef ONLINE_JUDGE freopen("A.in", "r", stdin); #endif for (int T = read(); T--; solve()); return0; }
#include<bits/stdc++.h> #define ins insert intread(int x = 0, int f = 0, char ch = getchar()) { while (ch < 48or57 < ch) f = ch == 45, ch = getchar(); while(48 <= ch and ch <= 57) x = x * 10 + ch - 48, ch = getchar(); return f ? -x : x; } constint N = 3e5 + 5; int n, a[N], d[N];
voidsolve() { n = read(); for (int i = 1; i <= n; i++) a[i] = read(); for (int i = 1; i <= n; i++) d[i] = read(); d[0] = d[n + 1] = INT32_MAX, a[0] = a[n + 1] = 0; std::set<int> lft, cur; for (int i = 0; i <= n + 1; i++) lft.ins(i), cur.ins(i); for (; n--; ) { std::set<int> del, ncur; for (int i : cur) { auto it = lft.find(i); if (it == lft.end()) continue; int L = *std::prev(it); int R = *std::next(it); if (a[L] + a[R] > d[i]) del.ins(i), ncur.ins(L), ncur.ins(R); } std::cout << del.size() << ' '; for (auto it : del) lft.erase(it); cur = ncur; } puts(""); }
intmain() { #ifndef ONLINE_JUDGE freopen("D.in", "r", stdin); #endif for (int T = read(); T--; solve()); return0; }