Submission #6426599


Source Code Expand

Copy
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;

int main()
{
    string s, t;
    cin >> s >> t;

    set<char> used;
    vector<char> table('z' + 1);
    for (char i = 'a'; i <= 'z'; i++)
    {
        table[i] = i;
    }

    for (size_t i = 0; i < s.length(); i++)
    {
        if (table[s[i]] != t[i])
        {
            char c1 = table[s[i]];
            char c2 = t[i];
            if (used.find(c2) != used.end())
            {
                cout << "No" << endl;
                return 0;
            }

            table[c1] = c2;

            if (table[table[c2]] != table[c2])
            {
                table[table[c2]] = c1;
            }
            else
            {
                table[c2] = c1;
            }
            used.insert(c2);
        }
    }
    cout << "Yes" << endl;

    return 0;
}

Submission Info

Submission Time
Task C - String Transformation
User nksymsym
Language C++14 (GCC 5.4.1)
Score 0
Code Size 941 Byte
Status
Exec Time 14 ms
Memory 776 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 sample_01, sample_02, sample_03
All 0 / 300 0_min0, 0_min1, 1_small0, 1_small1, 1_small2, 2_medium0, 2_medium1, 2_medium2, 2_medium3, 2_medium4, 3_max0, 3_max1, 3_max2, 3_max3, 3_max4, 3_max5, 3_max6, 3_max7, 3_max8, 3_max9, 5_hand0, sample_01, sample_02, sample_03
Case Name Status Exec Time Memory
0_min0 1 ms 256 KB
0_min1 1 ms 256 KB
1_small0 1 ms 256 KB
1_small1 1 ms 256 KB
1_small2 1 ms 256 KB
2_medium0 11 ms 772 KB
2_medium1 10 ms 772 KB
2_medium2 3 ms 384 KB
2_medium3 13 ms 776 KB
2_medium4 10 ms 772 KB
3_max0 14 ms 776 KB
3_max1 14 ms 776 KB
3_max2 14 ms 776 KB
3_max3 14 ms 776 KB
3_max4 14 ms 776 KB
3_max5 14 ms 776 KB
3_max6 14 ms 776 KB
3_max7 14 ms 776 KB
3_max8 14 ms 776 KB
3_max9 14 ms 776 KB
5_hand0 1 ms 256 KB
sample_01 1 ms 256 KB
sample_02 1 ms 256 KB
sample_03 1 ms 256 KB