prompt
string
response
string
Problem: There are n startups. Startups can be active or acquired. If a startup is acquired, then that means it has exactly one active startup that it is following. An active startup can have arbitrarily many acquired startups that are following it. An active startup cannot follow any other startup. The following step...
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; long long read() { long long a = 0; bool opt = 0; char c = getchar(); while (c < '0' || c > '9') opt |= c == '-', c = getchar(); while (c >= '0' && c <= '9') a = (a << 3) + (a << 1) + (c ^ 48), c = getchar(); return opt ? -a : a; } i...
Problem: There are n startups. Startups can be active or acquired. If a startup is acquired, then that means it has exactly one active startup that it is following. An active startup can have arbitrarily many acquired startups that are following it. An active startup cannot follow any other startup. The following step...
#include <bits/stdc++.h> using namespace std; int i, j, k, t, m, a[505], n; long long p[505] = {1}, res; int main() { scanf("%d", &n); for (i = 1; i <= 500; i++) { p[i] = p[i - 1] * 2 % 1000000007; } for (i = 1; i <= n; i++) { scanf("%d", &k); if (k == -1) { a[i]++; } else { a[k]++; ...
Problem: There are n startups. Startups can be active or acquired. If a startup is acquired, then that means it has exactly one active startup that it is following. An active startup can have arbitrarily many acquired startups that are following it. An active startup cannot follow any other startup. The following step...
#include <bits/stdc++.h> const int maxn = 507; const int mod = 1E9 + 7; int N, Pr[maxn], size[maxn]; int main() { Pr[0] = 1; for (int i = 1; i < maxn; ++i) { Pr[i] = Pr[i - 1] * 2; if (Pr[i] >= mod) Pr[i] -= mod; } scanf("%d", &N); for (int i = 1; i <= N; ++i) { int a; scanf("%d", &a); if ...
Problem: There are n startups. Startups can be active or acquired. If a startup is acquired, then that means it has exactly one active startup that it is following. An active startup can have arbitrarily many acquired startups that are following it. An active startup cannot follow any other startup. The following step...
#include <bits/stdc++.h> using namespace std; template <typename T> void maxtt(T& t1, T t2) { t1 = max(t1, t2); } template <typename T> void mintt(T& t1, T t2) { t1 = min(t1, t2); } bool debug = 0; int n, m, k; int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0}; string direc = "RDLU"; long long ln, lk, lm; void etp(b...
Problem: There are n startups. Startups can be active or acquired. If a startup is acquired, then that means it has exactly one active startup that it is following. An active startup can have arbitrarily many acquired startups that are following it. An active startup cannot follow any other startup. The following step...
#include <bits/stdc++.h> using namespace std; const int kNmax = 510; const int kMod = 1e9 + 7; int n, a[kNmax], pw[kNmax], res, cnt[kNmax]; int main() { pw[0] = 1; for (int i = 1; i < kNmax; i++) { pw[i] = (1LL * pw[i - 1] * 2) % kMod; } cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i]; if (a[...
Problem: There are n startups. Startups can be active or acquired. If a startup is acquired, then that means it has exactly one active startup that it is following. An active startup can have arbitrarily many acquired startups that are following it. An active startup cannot follow any other startup. The following step...
#include <bits/stdc++.h> template <typename T> inline void rd(T& x) { int si = 1; char c = getchar(); x = 0; while (!isdigit(c)) si = c == '-' ? -1 : si, c = getchar(); while (isdigit(c)) x = x * 10 + c - 48, c = getchar(); x *= si; } template <typename T, typename... Args> inline void rd(T& x, Args&... arg...
Problem: There are n startups. Startups can be active or acquired. If a startup is acquired, then that means it has exactly one active startup that it is following. An active startup can have arbitrarily many acquired startups that are following it. An active startup cannot follow any other startup. The following step...
#include <bits/stdc++.h> using std::cin; using std::cout; const int maxn = 200200; const int mod = 1e9 + 7; inline long long pow(long long a, int b, int ans = 1) { for (; b; b >>= 1, a = a * a % mod) if (b & 1) ans = ans * a % mod; return ans; } inline long long inverse(int x) { return pow(x, mod - 2); } int cn...
Problem: There are n startups. Startups can be active or acquired. If a startup is acquired, then that means it has exactly one active startup that it is following. An active startup can have arbitrarily many acquired startups that are following it. An active startup cannot follow any other startup. The following step...
#include <bits/stdc++.h> using namespace std; long long mod = 1000000007; long long quickmod(long long a, long long b) { long long ans = 1; while (b) { if (b & 1) ans = (ans * a) % mod; a = (a * a) % mod; b >>= 1; } return ans; } long long a[1005]; signed main() { long long n; scanf("%lld", &n);...
Problem: There are n startups. Startups can be active or acquired. If a startup is acquired, then that means it has exactly one active startup that it is following. An active startup can have arbitrarily many acquired startups that are following it. An active startup cannot follow any other startup. The following step...
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.util.StringTokenizer; public class DivCmb_505G { public static void main(String[] args) throws IOException { Buffere...
Problem: There are n startups. Startups can be active or acquired. If a startup is acquired, then that means it has exactly one active startup that it is following. An active startup can have arbitrarily many acquired startups that are following it. An active startup cannot follow any other startup. The following step...
#include <bits/stdc++.h> using namespace std; long long qpow(long long x, long long k, long long mod) { long long ret = 1; while (k) { if (k & 1) { ret = ret * x; ret = ret % mod; } x = x * x; x = x % mod; k = (k >> 1); } return ret; } const int Maxn = 505; const int md = 1e9 + 7...
Problem: There are n startups. Startups can be active or acquired. If a startup is acquired, then that means it has exactly one active startup that it is following. An active startup can have arbitrarily many acquired startups that are following it. An active startup cannot follow any other startup. The following step...
#include <bits/stdc++.h> const int maxn = 100050; const double pi = acos(-1); using namespace std; int pw[maxn], cnt[maxn]; int n; long long qpow(long long x, long long n) { long long res = 1; while (n) { if (n & 1) res = res * x % 1000000007; x = x * x % 1000000007; n >>= 1; } return res; } int mai...
Problem: There are n startups. Startups can be active or acquired. If a startup is acquired, then that means it has exactly one active startup that it is following. An active startup can have arbitrarily many acquired startups that are following it. An active startup cannot follow any other startup. The following step...
#include <bits/stdc++.h> using namespace std; const int N = 510, Mo = 1000000007; int d[N], c[N]; inline int gi() { int x = 0, o = 1; char ch = getchar(); while (ch != '-' && (ch < '0' || ch > '9')) ch = getchar(); if (ch == '-') o = -1, ch = getchar(); while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch...
Problem: There are n startups. Startups can be active or acquired. If a startup is acquired, then that means it has exactly one active startup that it is following. An active startup can have arbitrarily many acquired startups that are following it. An active startup cannot follow any other startup. The following step...
#include <bits/stdc++.h> const int mod = 1000000007; int n, x, er[501], num[501], ans; int main() { scanf("%d", &n); er[0] = 0; for (int i = 1; i <= n; i++) er[i] = (er[i - 1] << 1 | 1) % mod; memset(num, 0, sizeof(num)); ans = er[n - 1]; for (int i = 1; i <= n; i++) { scanf("%d", &x); if (x > 0) nu...
Problem: There are n startups. Startups can be active or acquired. If a startup is acquired, then that means it has exactly one active startup that it is following. An active startup can have arbitrarily many acquired startups that are following it. An active startup cannot follow any other startup. The following step...
m = 1000000007 n = int(input()) a = input().split() print((pow(2,n-1,m)-1 - sum(pow(2,a.count(x),m)-1 for x in set(a) if x != '-1')) % m)
Problem: There are n startups. Startups can be active or acquired. If a startup is acquired, then that means it has exactly one active startup that it is following. An active startup can have arbitrarily many acquired startups that are following it. An active startup cannot follow any other startup. The following step...
#include <bits/stdc++.h> using namespace std; inline long long read() { long long x = 0, y = 1; char ch = getchar(); while (!isdigit(ch)) { if (ch == '-') y = -y; ch = getchar(); } while (isdigit(ch)) { x = x * 10 + ch - '0'; ch = getchar(); } return x * y; } namespace qiqi { const int N =...
Problem: There are n startups. Startups can be active or acquired. If a startup is acquired, then that means it has exactly one active startup that it is following. An active startup can have arbitrarily many acquired startups that are following it. An active startup cannot follow any other startup. The following step...
#include <bits/stdc++.h> using namespace std; const int MAXN = 100005; const int P = 1e9 + 7; template <typename T> void chkmax(T &x, T y) { x = max(x, y); } template <typename T> void chkmin(T &x, T y) { x = min(x, y); } template <typename T> void read(T &x) { x = 0; int f = 1; char c = getchar(); for (; !...
Problem: There are n startups. Startups can be active or acquired. If a startup is acquired, then that means it has exactly one active startup that it is following. An active startup can have arbitrarily many acquired startups that are following it. An active startup cannot follow any other startup. The following step...
#include <bits/stdc++.h> using namespace std; int n, fat[505], son[505]; int Pow(int a, int k) { int ret = 1; while (k) { if (k & 1) ret = (long long)ret * a % 1000000007; a = (long long)a * a % 1000000007; k >>= 1; } return ret; } int main() { scanf("%d", &n); for (int i = 1; i <= n; i++) { ...
Problem: There are n startups. Startups can be active or acquired. If a startup is acquired, then that means it has exactly one active startup that it is following. An active startup can have arbitrarily many acquired startups that are following it. An active startup cannot follow any other startup. The following step...
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.io.BufferedWriter; import java.io.Writer; import java.io.OutputStreamWriter; import java.util.InputMismatchException; import java.io.IOException; import java.io.Input...
Problem: There are n startups. Startups can be active or acquired. If a startup is acquired, then that means it has exactly one active startup that it is following. An active startup can have arbitrarily many acquired startups that are following it. An active startup cannot follow any other startup. The following step...
#include <bits/stdc++.h> using namespace std; const int M = 1000 * 1000 * 1000 + 7; int f(int x) { int res = 1; while (x--) { res = (res + res) % M; } res = (res + M - 1) % M; return res; } void solve() { int n; cin >> n; vector<int> v(n + 1, 0); for (int i = 0; i < (n); ++i) { int x; cin ...
Problem: There are n startups. Startups can be active or acquired. If a startup is acquired, then that means it has exactly one active startup that it is following. An active startup can have arbitrarily many acquired startups that are following it. An active startup cannot follow any other startup. The following step...
#include <bits/stdc++.h> using namespace std; template <typename T> void read(T &t) { t = 0; char ch = getchar(); int f = 1; while ('0' > ch || ch > '9') { if (ch == '-') f = -1; ch = getchar(); } do { (t *= 10) += ch - '0'; ch = getchar(); } while ('0' <= ch && ch <= '9'); t *= f; } con...
Problem: There are n startups. Startups can be active or acquired. If a startup is acquired, then that means it has exactly one active startup that it is following. An active startup can have arbitrarily many acquired startups that are following it. An active startup cannot follow any other startup. The following step...
#include <bits/stdc++.h> using namespace std; template <typename T> bool chkmin(T &x, T y) { return x > y ? x = y, 1 : 0; } template <typename T> bool chkmax(T &x, T y) { return x < y ? x = y, 1 : 0; } int readint() { int x = 0, f = 1; char ch = getchar(); while (ch < '0' || ch > '9') { if (ch == '-') f =...
Problem: There are n startups. Startups can be active or acquired. If a startup is acquired, then that means it has exactly one active startup that it is following. An active startup can have arbitrarily many acquired startups that are following it. An active startup cannot follow any other startup. The following step...
#include <bits/stdc++.h> using namespace std; template <class T> using min_pq = priority_queue<T, vector<T>, greater<T>>; const int MAXN = 2e5 + 10, MAXQ = 3e5 + 10, MAXL = 18, ALP = 26, MOD = 1e9 + 7, MAXK = 1e2 + 10, MAXA = 10, MAXB = 24, MAXBB = (1 << MAXB); const string no = "NO\n", yes = "YES\n"; const i...
Problem: There are n startups. Startups can be active or acquired. If a startup is acquired, then that means it has exactly one active startup that it is following. An active startup can have arbitrarily many acquired startups that are following it. An active startup cannot follow any other startup. The following step...
#include <bits/stdc++.h> using namespace std; const int N = 500 + 5, D = 1e9 + 7; int c[N], mi_2[N]; int main() { int n; cin >> n; for (int i = 1; i <= n; ++i) { int x; cin >> x; ++c[x == -1 ? i : x]; } mi_2[0] = 1; for (int i = 1; i <= n; ++i) mi_2[i] = mi_2[i - 1] * 2 % D; int ans = mi_2[n -...
Problem: There are n startups. Startups can be active or acquired. If a startup is acquired, then that means it has exactly one active startup that it is following. An active startup can have arbitrarily many acquired startups that are following it. An active startup cannot follow any other startup. The following step...
#include <bits/stdc++.h> using namespace std; inline int rd() { int x = 0; char c = getchar(); bool f = 0; while (c < '0' && c != '-') c = getchar(); if (c == '-') f = 1, c = getchar(); while (c >= '0') x = (x << 3) + (x << 1) + (c ^ 48), c = getchar(); return f ? -x : x; } const int Mod = 1e9 + 7; const ...
Problem: There are n startups. Startups can be active or acquired. If a startup is acquired, then that means it has exactly one active startup that it is following. An active startup can have arbitrarily many acquired startups that are following it. An active startup cannot follow any other startup. The following step...
#include <bits/stdc++.h> using namespace std; inline int read() { int s = 0, ch = getchar(), w = 1; while (ch < '0' || ch > '9') { if (ch == '-') w = -1; ch = getchar(); } while (ch >= '0' && ch <= '9') s = s * 10 + ch - '0', ch = getchar(); return s * w; } inline long long Read() { long long s = 0;...
Problem: There are n startups. Startups can be active or acquired. If a startup is acquired, then that means it has exactly one active startup that it is following. An active startup can have arbitrarily many acquired startups that are following it. An active startup cannot follow any other startup. The following step...
#include <bits/stdc++.h> using namespace std; template <typename T> inline bool ckmin(T &a, const T &b) { return b < a ? a = b, 1 : 0; } template <typename T> inline bool ckmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; } const int N = 500 + 10, P = 1e9 + 7; int n; int cnt[N], id[N], tot = 0; int qpow(int a, ...
Problem: There are n startups. Startups can be active or acquired. If a startup is acquired, then that means it has exactly one active startup that it is following. An active startup can have arbitrarily many acquired startups that are following it. An active startup cannot follow any other startup. The following step...
public class Main { public static void main(String[] args) { final int number = (int) 1e9 + 7; java.util.Scanner scanner = new java.util.Scanner(System.in); int n = scanner.nextInt(); int[] array1 = new int[n + 1], array2 = new int[n]; array1[0] = 1; for (int i = 1; ...
Problem: There are n startups. Startups can be active or acquired. If a startup is acquired, then that means it has exactly one active startup that it is following. An active startup can have arbitrarily many acquired startups that are following it. An active startup cannot follow any other startup. The following step...
#include <bits/stdc++.h> using namespace std; int n; long long qp(long long x, long long y) { long long r = 1; for (; y; y >>= 1, x = x * x % 1000000007ll) if (y & 1) r = r * x % 1000000007ll; return r; } long long c[1000010]; int main() { scanf("%d", &n); for (int i = 1; i <= n; i++) { int x; sca...
Problem: There are n startups. Startups can be active or acquired. If a startup is acquired, then that means it has exactly one active startup that it is following. An active startup can have arbitrarily many acquired startups that are following it. An active startup cannot follow any other startup. The following step...
#include <bits/stdc++.h> using namespace std; using INT = long long; using pii = pair<int, int>; int a[510]; int pw[510], cnt[510]; int main() { pw[0] = 1; for (int i = 1; i < 510; i++) pw[i] = (INT)pw[i - 1] * 2 % 1000000007; int n; cin >> n; for (int i = 1; i <= n; i++) { scanf("%d", &a[i]); if (a[i...
Problem: After learning a lot about space exploration, a little girl named Ana wants to change the subject. Ana is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given string whether it's a palindrome or not, but soon she grew tired of this prob...
#include <bits/stdc++.h> int N, alf[26]; long long ans; std::string s; std::map<int, int> m[27]; int main() { std::cin >> N; for (int i = 0; i < N; ++i) { std::cin >> s; for (int j = 0; j < 26; ++j) alf[j] = 0; for (int j = 0; j < s.size(); ++j) { ++alf[s[j] - 'a']; } int odd = 0, flag = 0...
Problem: After learning a lot about space exploration, a little girl named Ana wants to change the subject. Ana is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given string whether it's a palindrome or not, but soon she grew tired of this prob...
#include <bits/stdc++.h> using namespace std; inline void file() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); if (0) { freopen(".in", "r", stdin); freopen(".out", "w", stdout); } } const int PX[8] = {1, 0, -1, 0, 1, 1, -1, -1}, PY[8] = {0, 1, 0, -1, -1, 1, 1, -1}, N = (...
Problem: After learning a lot about space exploration, a little girl named Ana wants to change the subject. Ana is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given string whether it's a palindrome or not, but soon she grew tired of this prob...
#include <bits/stdc++.h> using namespace std; int i, j; const int M = 1e5 + 6, MAX = (1 << 26) + 6; int tcnt[26]; string s[M]; int x[M]; map<int, int> cnt; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); ; int n; cin >> n; long long ans = 0; while (n--) { string s; cin >> s; ...
Problem: After learning a lot about space exploration, a little girl named Ana wants to change the subject. Ana is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given string whether it's a palindrome or not, but soon she grew tired of this prob...
# Fast IO (only use in integer input) import os,io input=io.BytesIO(os.read(0,os.fstat(0).st_size)).readline MOD1 = 100000007 MOD2 = 1000000007 evenStrDict = {} oddStrDict = {} cnt = 0 N = int(input()) for _ in range(N): p = input() countList = [0] * 26 for elem in p: if elem < 97: ...
Problem: After learning a lot about space exploration, a little girl named Ana wants to change the subject. Ana is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given string whether it's a palindrome or not, but soon she grew tired of this prob...
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 5; unsigned long long seed = 131; unordered_map<unsigned long long, unsigned long long> mp; unsigned long long p[30]; void init() { p[0] = 131; for (int i = 1; i <= 26; i++) p[i] = p[i - 1] * seed; } char s[N]; int cnt[30]; unsigned long long a[N]; i...
Problem: After learning a lot about space exploration, a little girl named Ana wants to change the subject. Ana is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given string whether it's a palindrome or not, but soon she grew tired of this prob...
#include <bits/stdc++.h> using namespace std; const int SI = 1e5 + 100; map<int, int> val; long long ans; int N; char W[SI * 10]; int cnt[28]; int main() { scanf("%d", &N); for (int i = 1; i <= N; i++) { scanf("%s", W); memset(cnt, 0, sizeof(cnt)); int len = strlen(W); for (int j = 0; j < len; j++) ...
Problem: After learning a lot about space exploration, a little girl named Ana wants to change the subject. Ana is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given string whether it's a palindrome or not, but soon she grew tired of this prob...
import sys import math import collections import heapq import decimal input=sys.stdin.readline n=int(input()) d={} ans=0 for i in range(n): s=input() k=len(s)-1 c=0 for j in range(k): c^=(1<<ord(s[j])-97) ans+=d.get(c,0) for j in range(26): ans+=d.get(c^(1<<j),0) k=d.get(c,0)...
Problem: After learning a lot about space exploration, a little girl named Ana wants to change the subject. Ana is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given string whether it's a palindrome or not, but soon she grew tired of this prob...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; unordered_map<string, int> mp; long long cnt = 0; for (int k = 0; k < n; k++) { string str; cin >> str; vector<int> arr(26, 0); for (int i = 0; i < str.size(); i++) ...
Problem: After learning a lot about space exploration, a little girl named Ana wants to change the subject. Ana is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given string whether it's a palindrome or not, but soon she grew tired of this prob...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); ; string s; int i, j, n; cin >> n; map<long long int, long long int> mp; long long int ans = 0; for (i = 0; i < n; i++) { cin >> s; int a[30] = {0}; for (j = 0; j <...
Problem: After learning a lot about space exploration, a little girl named Ana wants to change the subject. Ana is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given string whether it's a palindrome or not, but soon she grew tired of this prob...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<string> a(n); map<int, int> mp; long long ans = 0; for (int i = 0; i < n; i++) { cin >> a[i]; int val = 0; for (int j = 0; j < a[i].size(); j++) { val ^= (1 << (a[i][j] - 'a')); } if (mp.find(val) !=...
Problem: After learning a lot about space exploration, a little girl named Ana wants to change the subject. Ana is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given string whether it's a palindrome or not, but soon she grew tired of this prob...
#include <bits/stdc++.h> using namespace std; int A[100000]; int main() { ios::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; string line; map<int, int> B; for (int i = 0; i < n; ++i) { cin >> line; for (char c : line) A[i] ^= 1 << (c - 'a'); B[A[i]] += 1; } long long mx = 0; fo...
Problem: After learning a lot about space exploration, a little girl named Ana wants to change the subject. Ana is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given string whether it's a palindrome or not, but soon she grew tired of this prob...
# -*- coding:utf-8 -*- """ created by shuangquan.huang at 11/20/18 After learning a lot about space exploration, a little girl named Ana wants to change the subject. Ana is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given string whether...
Problem: After learning a lot about space exploration, a little girl named Ana wants to change the subject. Ana is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given string whether it's a palindrome or not, but soon she grew tired of this prob...
#include <bits/stdc++.h> using namespace std; int n; long long int ans = 0; int c['z' - 'a' + 1]; string p[100005]; map<int, int> mp; int get_bitmask(string s) { for (int i = 0; i < 'z' - 'a' + 1; i++) c[i] = 0; for (int i = 0; i < s.size(); i++) { c[s[i] - 'a']++; c[s[i] - 'a'] %= 2; } int bmsk = 0; ...
Problem: After learning a lot about space exploration, a little girl named Ana wants to change the subject. Ana is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given string whether it's a palindrome or not, but soon she grew tired of this prob...
#include <bits/stdc++.h> #pragma GCC optimize "-O3" using namespace std; int n; map<int, int> mm; int main() { ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0); long long ans = 0; cin >> n; for (int i = 0; i < n; ++i) { string s; cin >> s; int cur = 0; for (char c : s) cur ^= (1 << (c -...
Problem: After learning a lot about space exploration, a little girl named Ana wants to change the subject. Ana is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given string whether it's a palindrome or not, but soon she grew tired of this prob...
#include <bits/stdc++.h> #pragma GCC optimize "-O3" using namespace std; int n; map<int, int> mm; int main() { ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0); long long ans = 0; cin >> n; for (int i = 0; i < n; ++i) { string s; cin >> s; int cur = 0; for (char c : s) cur ^= (1 << (c -...
Problem: After learning a lot about space exploration, a little girl named Ana wants to change the subject. Ana is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given string whether it's a palindrome or not, but soon she grew tired of this prob...
import java.util.*; import java.io.*; public class Solution { public static void main(String []args) throws IOException { BufferedReader br = new BufferedReader( new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(br.readLine(...
Problem: After learning a lot about space exploration, a little girl named Ana wants to change the subject. Ana is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given string whether it's a palindrome or not, but soon she grew tired of this prob...
import java.util.*; import java.io.*; import java.math.*; import java.util.regex.*; public class Main4 { public static void main(String[] args)throws Exception { Reader reader = new Reader(); reader.readLine(); int n = reader.readInt(0); HashMap<Integer,Integer> freq = new HashMap<>(); long ans =...
Problem: After learning a lot about space exploration, a little girl named Ana wants to change the subject. Ana is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given string whether it's a palindrome or not, but soon she grew tired of this prob...
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.util.Arrays; import java.util.HashMap; import java.util.Map; import java.util.StringTokenizer; public class I { stati...
Problem: After learning a lot about space exploration, a little girl named Ana wants to change the subject. Ana is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given string whether it's a palindrome or not, but soon she grew tired of this prob...
#include <bits/stdc++.h> using namespace std; using namespace std; int change(int mask, int bit) { return mask ^ (1 << bit); } const int N = 2e5 + 5; int n, h[N]; map<int, int> cnt; string str; long long ans = 0; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n; for (int i = 0; i < n; ++i) { ...
Problem: After learning a lot about space exploration, a little girl named Ana wants to change the subject. Ana is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given string whether it's a palindrome or not, but soon she grew tired of this prob...
#include <bits/stdc++.h> using namespace std; int Power(int a, int b) { if (b == 0) return 1; if (b & 1) return a * Power(a, b - 1); int t = Power(a, b / 2); return t * t; } int GCD(int a, int b) { if (b == 0) return a; return GCD(b, a % b); } void solve() { long long n; cin >> n; map<string, long lon...
Problem: After learning a lot about space exploration, a little girl named Ana wants to change the subject. Ana is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given string whether it's a palindrome or not, but soon she grew tired of this prob...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long n, ans = 0; cin >> n; map<long long, long long> temp; for (int i = 0; i < n; i++) { string some; cin >> some; long long h = 0; for (int j = 0; j < some.size(); j++) {...
Problem: After learning a lot about space exploration, a little girl named Ana wants to change the subject. Ana is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given string whether it's a palindrome or not, but soon she grew tired of this prob...
#include <bits/stdc++.h> using namespace std; unordered_map<string, long long> mp; unordered_map<string, long long>::iterator it; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); long long n, luw = 0, kent1 = 0, p[27]; p[0] = 1; for (long long k = 1; k <= 26; k++) p[k] = p[k - 1] * 29...
Problem: After learning a lot about space exploration, a little girl named Ana wants to change the subject. Ana is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given string whether it's a palindrome or not, but soon she grew tired of this prob...
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 10; void run_case() { int n, i, j, k; cin >> n; vector<string> v(n); for (i = 0; i < n; i++) cin >> v[i]; map<int, int> m; long long ans = 0; int f[26]; for (i = 0; i < n; i++) { memset(f, 0, sizeof(f)); for (char c : v[i]) ++f[c ...
Problem: After learning a lot about space exploration, a little girl named Ana wants to change the subject. Ana is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given string whether it's a palindrome or not, but soon she grew tired of this prob...
#include <bits/stdc++.h> using namespace std; int n; map<int, int> was; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n; long long ans = 0; for (int i = 0; i < n; i++) { string s; cin >> s; int mask = 0; for (char c : s) mask ^= (1 << (c - 'a')); ans += was[mask]; for (...
Problem: After learning a lot about space exploration, a little girl named Ana wants to change the subject. Ana is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given string whether it's a palindrome or not, but soon she grew tired of this prob...
//package com.company; import java.util.HashMap; import java.util.Scanner; public class CF_1045_I { public static void main(String args[]) { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); String s[]=new String[n]; for(int i=0;i<n;++i) s[i]=sc.next(); Has...
Problem: After learning a lot about space exploration, a little girl named Ana wants to change the subject. Ana is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given string whether it's a palindrome or not, but soon she grew tired of this prob...
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 10; const long long mod = 998244353; int a[33]; int nu[maxn], now; string s; map<int, int> mp; int main() { ios::sync_with_stdio(false); int n; cin >> n; for (int i = 1; i <= n; ++i) { memset(a, 0, sizeof(a)); cin >> s; now = 0; ...
Problem: After learning a lot about space exploration, a little girl named Ana wants to change the subject. Ana is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given string whether it's a palindrome or not, but soon she grew tired of this prob...
#include <bits/stdc++.h> using namespace std; int main() { long long n; cin >> n; map<string, long long> mp; map<char, long long> t; for (long long y = 0; y < n; y++) { string s; cin >> s; for (long long i = 0; i < s.length(); i++) { t[s[i]]++; } s = ""; for (auto i = t.begin(); ...
Problem: After learning a lot about space exploration, a little girl named Ana wants to change the subject. Ana is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given string whether it's a palindrome or not, but soon she grew tired of this prob...
from collections import Counter n = int(input()) strings = [] for i in range(0,n): counter = { x: 0 for x in range(ord('a'), ord('z')+1) } napis = input() for val in napis: counter[ord(val)] = (counter[ord(val)] + 1) % 2 napis = "" for key, val in counter.items(): if val != 0: napis+=chr(ke...
Problem: After learning a lot about space exploration, a little girl named Ana wants to change the subject. Ana is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given string whether it's a palindrome or not, but soon she grew tired of this prob...
#include <bits/stdc++.h> using namespace std; int tc = 1, n, pow_2[30]; map<int, int> cnt; string str; int getHash() { int freq[30] = {0}; for (char c : str) freq[c - 'a']++; int hash = 0; for (int i = 0; i < 26; i++) hash += (freq[i] % 2) * pow_2[i]; return hash; } void preprocess() { ios::sync_with_stdio(...
Problem: After learning a lot about space exploration, a little girl named Ana wants to change the subject. Ana is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given string whether it's a palindrome or not, but soon she grew tired of this prob...
n = int(input()) string_count = {} for _ in range(n): s = str(input()) item_count={} for i,c in enumerate(s): item_count[c]=item_count.get(c,0)+1 s0=[] for i,x in enumerate('abcdefghijklmnopqrstuvwxyz'): if item_count.get(x,0)%2==1: s0.append(x) s1 = ''.join(s0) s...
Problem: After learning a lot about space exploration, a little girl named Ana wants to change the subject. Ana is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given string whether it's a palindrome or not, but soon she grew tired of this prob...
#include <bits/stdc++.h> using namespace std; template <typename T> inline T qmin(const T &x, const T &y) { return x < y ? x : y; } template <typename T> inline T qmax(const T &x, const T &y) { return x > y ? x : y; } template <typename T> inline bool getmin(T &x, const T &y) { return y < x ? x = y, true : false;...
Problem: After learning a lot about space exploration, a little girl named Ana wants to change the subject. Ana is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given string whether it's a palindrome or not, but soon she grew tired of this prob...
#include <bits/stdc++.h> using namespace std; int togglebit(int n, int k) { return (n ^ (1 << (k - 1))); } void solve() { long long int n; cin >> n; string s[n]; for (__typeof(n) i = (0) - ((0) > (n)); i != (n) - ((0) > (n)); i += 1 - 2 * ((0) > (n))) cin >> s[i]; map<int, int> cnt; for (__typeof...
Problem: After learning a lot about space exploration, a little girl named Ana wants to change the subject. Ana is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given string whether it's a palindrome or not, but soon she grew tired of this prob...
from collections import Counter n = int(input()) strings = [] for i in range(0,n): counter = { x: 0 for x in range(ord('a'), ord('z')+1) } napis = input() for val in napis: counter[ord(val)] = (counter[ord(val)] + 1) % 2 napis = "" for key, val in counter.items(): if val != 0: napis+=chr(ke...
Problem: After learning a lot about space exploration, a little girl named Ana wants to change the subject. Ana is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given string whether it's a palindrome or not, but soon she grew tired of this prob...
n = int(input()) odd_occ = [] alphabet = 'abcdefghijklmnopqrstuvwxyz' for k in range(n): s = input() occ = {} for l in range(len(s)): ltr = s[l] if not occ.get(ltr): occ[ltr] = 0 occ[ltr] += 1 odd_ltrs = "" #print(occ) for l in range(26): ltr = alp...
Problem: After learning a lot about space exploration, a little girl named Ana wants to change the subject. Ana is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given string whether it's a palindrome or not, but soon she grew tired of this prob...
def zamien(S): A = 26*[0] for znak in S: A[ord(znak)-ord('a')] += 1 return ''.join([str(i%2) for i in A]) def main(): A = {} wynik = 0 for i in range(int(input())): s = zamien(input()) wynik += A.get(s,0) for i in range(26): wynik += A.get(s[:i]+...
Problem: After learning a lot about space exploration, a little girl named Ana wants to change the subject. Ana is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given string whether it's a palindrome or not, but soon she grew tired of this prob...
#include <bits/stdc++.h> using namespace std; const int maxn = 1e6 + 10; char arr[maxn]; int brr[30]; int nu[maxn]; map<int, int> mmp; int main(int argc, char const *argv[]) { int n; scanf("%d", &n); for (int i = 1; i <= n; ++i) { int now = 0; memset(brr, 0, sizeof brr); scanf("%s", arr); for (int...
Problem: After learning a lot about space exploration, a little girl named Ana wants to change the subject. Ana is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given string whether it's a palindrome or not, but soon she grew tired of this prob...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); long long n; cin >> n; map<string, long long> mp; map<char, long long> t; for (long long y = 0; y < n; y++) { string s; cin >> s; for (long long i = 0; i < s.length(); i++) { t[s[i]]++; ...
Problem: After learning a lot about space exploration, a little girl named Ana wants to change the subject. Ana is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given string whether it's a palindrome or not, but soon she grew tired of this prob...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long int n; cin >> n; map<string, long long int> count; for (long long int i = 0; i < n; i++) { string s; cin >> s; vector<long long int> cc(26, 0); for (long lo...
Problem: After learning a lot about space exploration, a little girl named Ana wants to change the subject. Ana is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given string whether it's a palindrome or not, but soon she grew tired of this prob...
#include <bits/stdc++.h> using ll = long long; int main() { std::ios_base::sync_with_stdio(false); std::cin.tie(nullptr); int n; std::cin >> n; std::vector<int> vec(n); for (int i = 0; i < n; ++i) { std::string s; std::cin >> s; int mask = 0; for (int j = 0; j < (int)s.length(); ++j) { ...
Problem: After learning a lot about space exploration, a little girl named Ana wants to change the subject. Ana is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given string whether it's a palindrome or not, but soon she grew tired of this prob...
#include <bits/stdc++.h> using namespace std; const long long int mod = 1000000007; const long long int inf = 1e17; const long long int N = 1e5 + 5; int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long int n; cin >> n; map<long long int, long long int> m; for (long long int i ...
Problem: After learning a lot about space exploration, a little girl named Ana wants to change the subject. Ana is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given string whether it's a palindrome or not, but soon she grew tired of this prob...
#include <bits/stdc++.h> template <typename T> inline void read(T &x) { x = 0; register char ch; register bool fl = 0; while (ch = getchar(), ch < 48 || 57 < ch) fl ^= ch == '-'; x = (ch & 15); while (ch = getchar(), 47 < ch && ch < 58) x = (x << 1) + (x << 3) + (ch & 15); if (fl) x = -x; } template <...
Problem: After learning a lot about space exploration, a little girl named Ana wants to change the subject. Ana is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given string whether it's a palindrome or not, but soon she grew tired of this prob...
#include <bits/stdc++.h> using namespace std; const int M = 26; const int N = 1e5 + 10; map<int, int> h; int a[N]; int main() { int n; cin >> n; long long ans = 0; while (n--) { string s; cin >> s; int pos = 0; for (auto ch : s) pos ^= 1 << (ch - 'a'); ans += h[pos]; for (int j = 0; j < ...
Problem: After learning a lot about space exploration, a little girl named Ana wants to change the subject. Ana is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given string whether it's a palindrome or not, but soon she grew tired of this prob...
N = int(input()) repo = {} # empty dictionary total_count = 0 for i in range(N): val = input() # we need to convert val into 01010101010101010101010101 # use bit-wise num = 0 for c in val: index = ord(c) - ord('a') num ^= (1 << index) # this is to flip the binary at the index #...
Problem: After learning a lot about space exploration, a little girl named Ana wants to change the subject. Ana is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given string whether it's a palindrome or not, but soon she grew tired of this prob...
#include <bits/stdc++.h> using namespace std; void draganov47() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); } int main() { draganov47(); int n; cin >> n; unordered_map<long long, long long> mapa; long long ans = 0; for (int i = 0; i < n; i++) { string s; cin >> s; long long cn...
Problem: After learning a lot about space exploration, a little girl named Ana wants to change the subject. Ana is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given string whether it's a palindrome or not, but soon she grew tired of this prob...
n = int(input()) string_count = {} for _ in range(n): s = str(input()) item_count={} for i,c in enumerate(s): item_count[c]=item_count.get(c,0)+1 s0=[] for x in 'abcdefghijklmnopqrstuvwxyz': if item_count.get(x,0)%2==1: s0.append(x) s1 = ''.join(s0) string_count[s...
Problem: After learning a lot about space exploration, a little girl named Ana wants to change the subject. Ana is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given string whether it's a palindrome or not, but soon she grew tired of this prob...
n=int(input()) s=[0]*n for i in range (n): s[i]=input() dic={} ans=0 for i in range (n): temp=0 for k in range(len(s[i])): temp^=(1<<(ord(s[i][k])-ord('a'))) #print(temp,s[i]) if temp in dic.keys(): ans=ans+dic[temp] for j in range (26): chk=temp chk^=(1<<j) ...
Problem: After learning a lot about space exploration, a little girl named Ana wants to change the subject. Ana is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given string whether it's a palindrome or not, but soon she grew tired of this prob...
#include <bits/stdc++.h> #pragma comment(linker, "/STACK:256000000") using namespace std; const long long MOD = 16714589; const int dx[] = {0, 1, 0, -1}; const int dy[] = {1, 0, -1, 0}; const int MAXN = (int)1e5 + 500; const long long N = (long long)1e6; const double EPS = 1e-10; const double PI = 3.1415926535897932384...
Problem: After learning a lot about space exploration, a little girl named Ana wants to change the subject. Ana is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given string whether it's a palindrome or not, but soon she grew tired of this prob...
def daj_maske(slowo): maska = 0 for litera in slowo: kod = ord(litera) - ord('a') maska ^= (1 << kod) return maska n = int(input()) L = [] for _ in range(n): slowo = input() L.append(slowo) wynik = 0 zlicz = {} for slowo in L: maska = daj_maske(slowo) wynik += zlicz.get...
Problem: After learning a lot about space exploration, a little girl named Ana wants to change the subject. Ana is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given string whether it's a palindrome or not, but soon she grew tired of this prob...
#include <bits/stdc++.h> #pragma gcc optimize("Ofast") using namespace std; template <typename T> using maxHeap = priority_queue<T, vector<T>, less<T>>; template <typename T> using minHeap = priority_queue<T, vector<T>, greater<T>>; inline void input(int& _x) { _x = 0; int _tmp = 1; char _tc = getchar(); while ...
Problem: After learning a lot about space exploration, a little girl named Ana wants to change the subject. Ana is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given string whether it's a palindrome or not, but soon she grew tired of this prob...
#include <bits/stdc++.h> using namespace std; int static_init = []() { ios_base::sync_with_stdio(false), cin.tie(0), cout << fixed; return 0; }(); int main() { int n; cin >> n; string s; int64_t ans = 0; unordered_map<bitset<26>, int32_t> cnt(n); for (int i = 0; i < n; i++) { cin >> s; bitset<26...
Problem: After learning a lot about space exploration, a little girl named Ana wants to change the subject. Ana is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given string whether it's a palindrome or not, but soon she grew tired of this prob...
#include <bits/stdc++.h> using namespace std; struct Str { bool num[26]; inline bool operator<(Str b) const { for (register int i = 0; i < 26; ++i) if (num[i] != b.num[i]) return num[i]; return 0; } inline bool operator==(Str b) const { for (register int i = 0; i < 26; ++i) if (num[i] !=...
Problem: After learning a lot about space exploration, a little girl named Ana wants to change the subject. Ana is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given string whether it's a palindrome or not, but soon she grew tired of this prob...
#include <bits/stdc++.h> using namespace std; bool chk(vector<int>& s1, vector<int>& s2, int sz) { int c = 0; for (int i = 0; i < 27; i++) { if ((s1[i] + s2[i]) % 2 != 0) c += 1; } if (c == 0) return true; if (c > 1) return false; if (c == 1) { if (sz % 2 != 0) return true; else retu...
Problem: After learning a lot about space exploration, a little girl named Ana wants to change the subject. Ana is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given string whether it's a palindrome or not, but soon she grew tired of this prob...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; map<int, int> cnt; for (int i = 0; i < n; i++) { string s; cin >> s; int mask = 0; for (auto c : s) { mask ^= (1 << (c - 'a')); } cnt[mask]++; } long long int x = 0, y = 0; for (auto p : cnt) { in...
Problem: After learning a lot about space exploration, a little girl named Ana wants to change the subject. Ana is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given string whether it's a palindrome or not, but soon she grew tired of this prob...
#include <bits/stdc++.h> using namespace std; map<int, int> st; int n; string s; int main() { long long ans = 0; cin >> n; for (int i = 0; i < int(n); i++) { cin >> s; int a = 0; for (int j = 0; j < int((int)s.size()); j++) a ^= 1 << s[j] - 'a'; ans += st[a]; for (int j = 0; j < int(26); j++) ...
Problem: After learning a lot about space exploration, a little girl named Ana wants to change the subject. Ana is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given string whether it's a palindrome or not, but soon she grew tired of this prob...
import java.util.*; public class PalindromePairs { public static void main(String[] args) { Scanner scan=new Scanner(System.in); int n=scan.nextInt(); HashMap<Integer,Integer> f=new HashMap<>(); int[] masks=new int[n]; for(int i=0;i<n;i++) { String s=scan.next(); int mask=mask(s); f.put(mask,f.getO...
Problem: After learning a lot about space exploration, a little girl named Ana wants to change the subject. Ana is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given string whether it's a palindrome or not, but soon she grew tired of this prob...
import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.*; public class Code { public static String odds(String s) { int[] arr = new int[28]; for(int i=0;i<s.length();i++) { a...
Problem: After learning a lot about space exploration, a little girl named Ana wants to change the subject. Ana is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given string whether it's a palindrome or not, but soon she grew tired of this prob...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int N; cin >> N; long long ans = 0; map<long long, int> cnt; for (int i = 0; i < N; i++) { string g; cin >> g; int u = 0; for (auto c : g) { u ^= 1 << (c - 'a'); } ...
Problem: After learning a lot about space exploration, a little girl named Ana wants to change the subject. Ana is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given string whether it's a palindrome or not, but soon she grew tired of this prob...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; map<int, int> M1; long long int ans = 0; while (n--) { string s; cin >> s; int x = 0; for (int i = 0; i < s.length(); i++) { int pos = s[i] - 97; int t = (int)pow(2, pos); x = x ^ t; } ans = a...
Problem: After learning a lot about space exploration, a little girl named Ana wants to change the subject. Ana is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given string whether it's a palindrome or not, but soon she grew tired of this prob...
#include <bits/stdc++.h> using namespace std; map<int, int> cnt; long long ans; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n; cin >> n; for (int i = 1; i <= n; ++i) { string s; cin >> s; int val = 0; for (int j = 0; j < s.size(); ++j) { int x = s[...
Problem: After learning a lot about space exploration, a little girl named Ana wants to change the subject. Ana is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given string whether it's a palindrome or not, but soon she grew tired of this prob...
#include <bits/stdc++.h> using namespace std; const int N = 1000002; int n, cnt[26]; char a[N]; long long ans; map<int, int> first; vector<int> v; int main() { scanf("%d", &n); for (int i = 1; i <= n; ++i) { scanf("%s", a); int m = strlen(a); memset(cnt, 0, sizeof cnt); for (int j = 0; j <= m - 1; +...
Problem: After learning a lot about space exploration, a little girl named Ana wants to change the subject. Ana is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given string whether it's a palindrome or not, but soon she grew tired of this prob...
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5, M = 8e7 + 5; int a[N], bin[30], n; long long ans; char s[N * 10]; map<int, int> cnt; int main() { bin[0] = 1; for (int i = 1; i < 26; ++i) bin[i] = bin[i - 1] << 1; scanf("%d", &n); for (int i = 1; i <= n; ++i) { scanf("%s", s + 1); in...
Problem: After learning a lot about space exploration, a little girl named Ana wants to change the subject. Ana is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given string whether it's a palindrome or not, but soon she grew tired of this prob...
import java.io.*; import java.util.*; public class i { public static void main(String[] args) { new i(); } i() { FastScanner fs = new FastScanner(); int n = fs.nextInt(); String[] a = new String[n]; for(int i = 0; i < n; i++) { a[i] = fs.next(); } HashMap<Integer, Integer> map = new HashMap<>(); ...
Problem: After learning a lot about space exploration, a little girl named Ana wants to change the subject. Ana is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given string whether it's a palindrome or not, but soon she grew tired of this prob...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; map<int, int> fuck; long long ans = 0; for (int k = 0; k < n; k++) { string s; cin >> s; int d = 0; for (int j = 0; j < s.size(); j++) { char c = s[j] - 'a'; d ^= (1 << c); } if (fuck.count(d)) ans ...
Problem: After learning a lot about space exploration, a little girl named Ana wants to change the subject. Ana is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given string whether it's a palindrome or not, but soon she grew tired of this prob...
#include <bits/stdc++.h> using namespace std; map<int, int> hashing_count; int xuli(vector<char> a) { int kq = 0; for (auto item : a) { kq += 1 << (item - 'a'); } return kq; } long long nhich(int value, vector<char> my_stack) { long long res = 0; for (auto kitu : my_stack) { int cur_value = value - ...
Problem: After learning a lot about space exploration, a little girl named Ana wants to change the subject. Ana is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given string whether it's a palindrome or not, but soon she grew tired of this prob...
#include <bits/stdc++.h> using namespace std; const int inf = (int)1e9; const int mod = inf + 7; const double eps = 1e-9; const double pi = acos(-1.0); long long read_long() { long long ans = 0; char c; bool started = false; bool is_negative = false; while (true) { c = getchar(); if ((c < '0' || c > '...
Problem: After learning a lot about space exploration, a little girl named Ana wants to change the subject. Ana is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given string whether it's a palindrome or not, but soon she grew tired of this prob...
from collections import Counter s=[] for i in range(int(input())): x=[0]*26 for j in input().strip(): x[ord(j)-97]^=1 s.append(''.join([str(y) for y in x ])) z=Counter(s) #print(s) an=0 for j in s: x=list(j) for q in range(len(x)): if x[q]=='1': x[q]='0' ...
Problem: After learning a lot about space exploration, a little girl named Ana wants to change the subject. Ana is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given string whether it's a palindrome or not, but soon she grew tired of this prob...
#include <bits/stdc++.h> using namespace std; bool chk(vector<int>& s1, vector<int>& s2, int sz) { int c = 0; for (int i = 0; i < 27; i++) { if ((s1[i] + s2[i]) % 2 != 0) c += 1; } if (c == 0) return true; if (c > 1) return false; if (c == 1) { if (sz % 2 != 0) return true; else retu...
Problem: After learning a lot about space exploration, a little girl named Ana wants to change the subject. Ana is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given string whether it's a palindrome or not, but soon she grew tired of this prob...
#include <bits/stdc++.h> using namespace std; const double pi = 2 * acos(0.0); const int maxn = 2e5 + 10; const int maxm = 4e5 + 10; const int mod = 1e9 + 7; map<string, long long> mp; string ss[maxn]; bool cmp(string A, string B) { if (A.length() == B.length()) return A < B; else return A.length() < B.leng...
Problem: After learning a lot about space exploration, a little girl named Ana wants to change the subject. Ana is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given string whether it's a palindrome or not, but soon she grew tired of this prob...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using pi = pair<int, int>; using pll = pair<ll, ll>; constexpr int INF = 0x3f3f3f3f; constexpr ll LLINF = 0x3f3f3f3f3f3f3f3f; template <class RIt> void dbarr(RIt frs, RIt lst) { cerr << "arr: "; for (int i = 0; i < (int)(lst...
Problem: After learning a lot about space exploration, a little girl named Ana wants to change the subject. Ana is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given string whether it's a palindrome or not, but soon she grew tired of this prob...
#include <bits/stdc++.h> using namespace std; const long long mod = 1000000007; inline int pow_(long long a, int n, int p = mod) { int r = 1; while (n) { if (n & 1) r = r * a % p; n >>= 1; a = a * a % p; } return r; } inline int inv_(int a) { return pow_(a, mod - 2, mod); } inline int add(int a, int...
Problem: After learning a lot about space exploration, a little girl named Ana wants to change the subject. Ana is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given string whether it's a palindrome or not, but soon she grew tired of this prob...
import java.util.*; import java.io.*; import static java.lang.System.out; public class Codeforces { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); } ...