Submission #61164732


Source Code Expand

Copy
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define fr(j, l,n) for(int j = l; j < int(n); j++)
#define fn(j,n,l) for(int j=n-1;j>=l;j--)
#define gets(s) string s; cin>>s;
#define all(v) v.begin(),v.end()
#define getv(v,n) vector<ll> v(n); fr(i,0,n) cin >> v[i];
#define seev(a) for(auto x:a){cout<<x<<" ";}cout<<endl;
#define vl vector<ll>
#define ve vector
#define vvl vector<vector<ll>>
#define vp vector<pair<ll,ll>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define pb push_back
#define mp make_pair
#define mse multiset<ll>
#define se set<ll>
#define ma map<ll,ll>
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define fr(j, l,n) for(int j = l; j < int(n); j++)
#define fn(j,n,l) for(int j=n-1;j>=l;j--) 
#define gets(s) string s; cin>>s;
#define all(v) v.begin(),v.end()
#define getv(v,n) vector<ll> v(n); fr(i,0,n) cin >> v[i];
#define seev(a) for(auto x:a){cout<<x<<" ";}cout<<endl;
#define vl vector<ll>
#define ve vector
#define vvl vector<vector<ll>>
#define vp vector<pair<ll,ll>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define pb push_back
#define mp make_pair
#define mse multiset<ll>
#define se set<ll>
#define ma map<ll,ll>
#define getmat(v,n,m) vector<vl>v(n,vl(m));fr(i,0,n) {fr (j,0,m) cin>>v[i][j];}
#define seemat(mat) for(auto row:mat){seev(row);}
#define YES cout<<"Yes\n";
#define NO cout<<"No\n";
using namespace std;
using namespace __gnu_pbds;

// Define ordered multiset with long long

typedef tree<long long, long long, less<long>, rb_tree_tag, tree_order_statistics_node_update> ordered_multimap;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

vl sieve;
void SieveOfEratosthenes(int n)
{
    // Create a boolean array "prime[0..n]" and initialize
    // all entries it as true. A value in prime[i] will
    // finally be false if i is Not a prime, else true.
    vl prime(n+1,true);
 
    for (int p = 2; p * p <= n; p++) {
        // If prime[p] is not changed, then it is a prime
        if (prime[p] == true) {
            // Update all multiples of p greater than or
            // equal to the square of it numbers which are
            // multiple of p and are less than p^2 are
            // already been marked.
            for (int i = p * p; i <= n; i += p)
                prime[i] = false;
        }
    }
 
    // Print all prime numbers
    for (int p = 2; p <= n; p++)
        if (prime[p])
            sieve.push_back(p);
}
bool sortbysec(const pair<ll, ll>& a,
               const pair<ll, ll>& b)
{
    return (a.second < b.second);
}
// gives gcd and the other coefficients
ll gcd(ll a, ll b, ll& x, ll& y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll x1, y1;
    ll d = gcd(b, a % b, x1, y1);
    x = y1;
    y = x1 - y1 * (a / b);
    return d;
}
// a raised to power b
ll pwr(ll a, ll b, ll mod = 0){
    ll result = 1;
    if(mod == 0){
        while(b){
            if(b & 1) result *= a;
            a *= a;
            b = b >> 1;
        }
    }
    else {
        while(b){
            if(b & 1){
                result *= a;
                result  = result % mod;
            }
            a *= a;
            a = a % mod;
            b = b >> 1;
        }
    }
    return result;
}
ll modularinverse(ll a,ll p)// p is prime
{
    return pwr(a,p-2,p);
}
// to convert string to binary(63 bits)
string tobin(ll a)
{
    string s;
    for (int i = 0; i < 63; i++)
    {
        if(a%2==1)
        {
            s+='1';
        }
        else
        {
            s+='0';
        }
        a>>=1;
    }
    return s;
}
int log2_floor(unsigned long long i) {
    return i ? 63 - __builtin_clzll(i) : -1;
    // -1 as log undefined for 0
}
// QUESTION DHANG SE PADHNA
void solve(ll tc){
    ll n=0,m=0,k=0,a=0,b=0,c=0,x=0,y=0,z=0;
    cin>>k;
    gets(s);
    gets(t);
    if(s==t)
    {
        // cout<<'1'<<endl;
        YES;
        return;
    }
    n=s.size();
    m=t.size();
    if(abs(n-m)>1)
    {
        NO;
        return;
    }
    if(s.size()==t.size())
    {
        for (int i = 0; i < s.size(); i++)
        {
            if(s[i]!=t[i])
            {
                a++;
            }
        }
        if(a<=1)
        {
            // cout<<'w'<<endl;
            YES;
            return;
        }
        NO;
        return;
    }
    if(n<m)
    {
        swap(s,t);
        swap(n,m);
        // cout<<n<<' '<<m<<endl;
        // cout<<s<<' '<<t<<endl;
    }
    if(n>m)
    {
        c=m;
        for (int i = 0; i < m; i++)
        {
            if(s[i]!=t[i])
            {
                c=i;
                break;
            }
        }
        if(c==m)
        {
            YES;
            return;
        }
        a=0;
        // cout<<c<<endl;
        for (int j = c; j<m; j++)
        {
            if(s[j+1]!=t[j])
            {
                NO;
                return;
            }
        }
        YES;
        
    }
    
    
}


int main(){

#ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
#endif
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);

int t=1;
// cin>>t;
ll tc=0;
while(t--){
    tc++;
    solve(tc);
}

return 0;
}

Submission Info

Submission Time
Task C - Operate 1
User DarshJainMe
Language C++ 20 (gcc 12.2)
Score 350
Code Size 4933 Byte
Status AC
Exec Time 3 ms
Memory 4472 KB

Compile Error

Main.cpp: In function ‘void solve(long long int)’:
Main.cpp:147:27: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::__cxx11::basic_string<char>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
  147 |         for (int i = 0; i < s.size(); i++)
      |                         ~~^~~~~~~~~~
Main.cpp:128:24: warning: unused variable ‘b’ [-Wunused-variable]
  128 |     ll n=0,m=0,k=0,a=0,b=0,c=0,x=0,y=0,z=0;
      |                        ^
Main.cpp:128:32: warning: unused variable ‘x’ [-Wunused-variable]
  128 |     ll n=0,m=0,k=0,a=0,b=0,c=0,x=0,y=0,z=0;
      |                                ^
Main.cpp:128:36: warning: unused variable ‘y’ [-Wunused-variable]
  128 |     ll n=0,m=0,k=0,a=0,b=0,c=0,x=0,y=0,z=0;
      |                                    ^
Main.cpp:128:40: warning: unused variable ‘z’ [-Wunused-variable]
  128 |     ll n=0,m=0,k=0,a=0,b=0,c=0,x=0,y=0,z=0;
      |                                        ^
Main.cpp:127:15: warning: unused parameter ‘tc’ [-Wunused-parameter]
  127 | void solve(ll tc){
      |               ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 350 / 350
Status
AC × 6
AC × 32
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt, sample_05.txt, sample_06.txt
All sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt, sample_05.txt, sample_06.txt, test_01.txt, test_02.txt, test_03.txt, test_04.txt, test_05.txt, test_06.txt, test_07.txt, test_08.txt, test_09.txt, test_10.txt, test_11.txt, test_12.txt, test_13.txt, test_14.txt, test_15.txt, test_16.txt, test_17.txt, test_18.txt, test_19.txt, test_20.txt, test_21.txt, test_22.txt, test_23.txt, test_24.txt, test_25.txt, test_26.txt
Case Name Status Exec Time Memory
sample_01.txt AC 1 ms 3472 KB
sample_02.txt AC 1 ms 3476 KB
sample_03.txt AC 1 ms 3476 KB
sample_04.txt AC 1 ms 3464 KB
sample_05.txt AC 1 ms 3416 KB
sample_06.txt AC 1 ms 3520 KB
test_01.txt AC 1 ms 3416 KB
test_02.txt AC 1 ms 3392 KB
test_03.txt AC 1 ms 3428 KB
test_04.txt AC 1 ms 3472 KB
test_05.txt AC 1 ms 3476 KB
test_06.txt AC 3 ms 4376 KB
test_07.txt AC 3 ms 4396 KB
test_08.txt AC 3 ms 4448 KB
test_09.txt AC 2 ms 4224 KB
test_10.txt AC 3 ms 4412 KB
test_11.txt AC 2 ms 3696 KB
test_12.txt AC 2 ms 3712 KB
test_13.txt AC 1 ms 3740 KB
test_14.txt AC 1 ms 3652 KB
test_15.txt AC 3 ms 4360 KB
test_16.txt AC 3 ms 4380 KB
test_17.txt AC 3 ms 4376 KB
test_18.txt AC 3 ms 4472 KB
test_19.txt AC 3 ms 4296 KB
test_20.txt AC 3 ms 4380 KB
test_21.txt AC 3 ms 4368 KB
test_22.txt AC 3 ms 4456 KB
test_23.txt AC 2 ms 4404 KB
test_24.txt AC 3 ms 4316 KB
test_25.txt AC 3 ms 4388 KB
test_26.txt AC 3 ms 4352 KB


2025-03-05 (Wed)
20:46:26 +00:00