Dear MikeMirzayanov , Today I received a mail saying the submission of Problem A and B coincides with a lot of many participants.
I don't know what they all submitted. I believe problem A was pretty straightforward, I saw the same solution in almost 90-95 % of participants after the Contest.
Talking about problem B, I did it by myself only. First I did it by map ,but got WA on Testcase 2 . After thinking a lot only solution was left in my mind was Brute Force for me which took a lot of time (for me).
I didn't involve in any unfair practice. I'm saying this because I have been wrongly penalized before also. I was new at this platform so didn't know how to appeal. But this time it's 2nd time that I have been penalized after giving fair competition also.
My 1st Solution for B (which got WA on TC-2 ) :
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define time cerr<<"Time taken : " <<(float)clock()/CLOCKS_PER_SEC <<" secs"<<"\n" ;
#define F first
#define S second
#define pb push_back
typedef long long int ll ;
const ll INF = (ll)1e18 ;
const ll MOD = (ll)1e9 + 7 ;
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
#else
#define trace(...)
#endif
ll GCD (ll a , ll b) {
if (b == 0) {
return a ;
}
return GCD(b , a % b) ;
}
ll LCM(ll a , ll b) {
return (a * b) / GCD(a , b) ;
}
vector<bool>sieveOfErato(ll n ) {
vector<bool>isPrime(n + 1 , true ) ;
isPrime[1] = false ;
isPrime[0] = false ;
for (ll i = 2 ; i * i <= n; i++) {
for (ll j = 2 * i ; j <= n; j += i) {
isPrime[j] = false;
}
}
return isPrime ;
}
void solve() {
map<char, int>m1 ;
map<char, int>m2;
string s1, s2 ;
cin >> s1 >> s2 ;
int n1 = s1.length() ; int n2 = s2.length() ;
for (int i = 0 ; i < s1.length() ; i++) {
m1[s1[i]]++;
}
for (int i = 0 ; i < s2.length() ; i++) {
m2[s2[i]]++;
}
if (m1.size() == m2.size() && m1.size() == 1) {
cout << "yes\n" ;
}
else {
bool ok = 1;
for (auto h : m1) {
if (h.S < m2[h.F]) {
ok = false;
break ;
}
}
if (ok == 0 && n1 == n2) {
ok = 1;
}
if (ok) {
cout << "yes\n" ;
}
else {
cout << "No\n" ;
}
}
}
int32_t main() {
fast ; time;
#ifndef ONLINE_JUDGE
freopen("input.txt" , "r" , stdin) ;
freopen("output.txt" , "w" , stdout) ;
#endif
int t = 1;
cin >> t;
while (t--) {
solve() ;
}
return 0 ;
}
After devoting a lot of time I finally came up with a brute force solution which got AC:
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define time cerr<<"Time taken : " <<(float)clock()/CLOCKS_PER_SEC <<" secs"<<"\n" ;
#define F first
#define S second
#define pb push_back
typedef long long int ll ;
const ll INF = (ll)1e18 ;
const ll MOD = (ll)1e9 + 7 ;
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
#else
#define trace(...)
#endif
ll GCD (ll a , ll b) {
if (b == 0) {
return a ;
}
return GCD(b , a % b) ;
}
ll LCM(ll a , ll b) {
return (a * b) / GCD(a , b) ;
}
vector<bool>sieveOfErato(ll n ) {
vector<bool>isPrime(n + 1 , true ) ;
isPrime[1] = false ;
isPrime[0] = false ;
for (ll i = 2 ; i * i <= n; i++) {
for (ll j = 2 * i ; j <= n; j += i) {
isPrime[j] = false;
}
}
return isPrime ;
}
void solve() {
string s1, s2;
cin >> s1 >> s2 ;
ll n1 = s1.length() ;
ll n2 = s2.length() ;
bool ans = 0 ;
for (ll i = 0 ; i < n1; i++) {
for (ll j = 0 ; j < n2; j++) {
if (s1[i] == s2[j]) {
ll m, left;
int x = 0 ;
for (left = j; left >= 0; left--) {
if (s2[left] != s1[i - x]) break ;
if (i < x) break ;
x++ ;
}
x = 0 ;
ll right;
for (right = j ; right < n2; right++) {
if (s2[right] != s1[i - x]) break;
if (i < x) break;
x++ ;
}
if (left == -1 && right == n2) {
ans = 1;
}
}
if (ans) break ;
}
if (ans) break ;
}
if (ans) {
cout << "yes\n" ;
}
else {
cout << "No\n" ;
}
}
int32_t main() {
fast ; time;
#ifndef ONLINE_JUDGE
freopen("input.txt" , "r" , stdin) ;
freopen("output.txt" , "w" , stdout) ;
#endif
int t = 1;
cin >> t;
while (t--) {
solve() ;
}
return 0 ;
}
I can say that this time also I didn't cheat and gave fair competition.
I hope you take the necessary steps regarding this and overturn the penalty.
Thank you to devote your time to read this blog