From dd684349c67c988ef19707cb65e637b6906fac75 Mon Sep 17 00:00:00 2001 From: omagdy7 Date: Fri, 8 Jul 2022 19:54:42 +0200 Subject: Solved some new problems --- codechef/Lapindromes/inp | 0 codechef/Lapindromes/main | Bin 0 -> 45968 bytes codechef/Lapindromes/main.cpp | 37 ++++++++++++++++++++++++++++++++++ codechef/Lapindromes/main_input0.txt | 7 +++++++ codechef/Lapindromes/main_output0.txt | 6 ++++++ 5 files changed, 50 insertions(+) create mode 100644 codechef/Lapindromes/inp create mode 100755 codechef/Lapindromes/main create mode 100644 codechef/Lapindromes/main.cpp create mode 100644 codechef/Lapindromes/main_input0.txt create mode 100644 codechef/Lapindromes/main_output0.txt (limited to 'codechef/Lapindromes') diff --git a/codechef/Lapindromes/inp b/codechef/Lapindromes/inp new file mode 100644 index 0000000..e69de29 diff --git a/codechef/Lapindromes/main b/codechef/Lapindromes/main new file mode 100755 index 0000000..4214922 Binary files /dev/null and b/codechef/Lapindromes/main differ diff --git a/codechef/Lapindromes/main.cpp b/codechef/Lapindromes/main.cpp new file mode 100644 index 0000000..d00f9e6 --- /dev/null +++ b/codechef/Lapindromes/main.cpp @@ -0,0 +1,37 @@ +#include + +using namespace std; + +int main () { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while(tt--){ + string s; + cin >> s; + int l = s.size(); + string le, ri; + if(l & 1) { + le = s.substr(0, l / 2); + ri = s.substr((l / 2) + 1, l); + } else { + le = s.substr(0, l / 2); + ri = s.substr(l / 2, l); + } + int ok = 1; + set st; + for(int i = 0; i < le.size(); i++) { + st.insert(le[i]); + } + for(auto x : st) { + int ls = count(le.begin(), le.end(), x); + int rs = count(ri.begin(), ri.end(), x); + if(ls != rs) { + ok = 0; + break; + } + } + cout << (ok ? "YES" : "NO") << endl; + } +} diff --git a/codechef/Lapindromes/main_input0.txt b/codechef/Lapindromes/main_input0.txt new file mode 100644 index 0000000..2776e7b --- /dev/null +++ b/codechef/Lapindromes/main_input0.txt @@ -0,0 +1,7 @@ +6 +gaga +abcde +rotor +xyzxy +abbaab +ababc diff --git a/codechef/Lapindromes/main_output0.txt b/codechef/Lapindromes/main_output0.txt new file mode 100644 index 0000000..faa6105 --- /dev/null +++ b/codechef/Lapindromes/main_output0.txt @@ -0,0 +1,6 @@ +YES +NO +YES +YES +NO +NO -- cgit v1.2.3