Submission details
Task:Swapping letters
Sender:kakuro
Submission time:2018-09-15 15:08:37 +0300
Language:C++
Status:READY
Result:
Test results
testverdicttime
#1ACCEPTED0.01 sdetails
#2ACCEPTED0.02 sdetails
#3ACCEPTED0.02 sdetails
#4ACCEPTED0.09 sdetails
#5ACCEPTED0.06 sdetails
#6--details
#7ACCEPTED0.41 sdetails
#8ACCEPTED0.06 sdetails
#9ACCEPTED0.06 sdetails
#10ACCEPTED0.06 sdetails

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:28:25: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
       for (ll cur=0; cur<x.length(); cur++) {
                      ~~~^~~~~~~~~~~

Code

#include <iostream>
#include <deque>
#include <algorithm>

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef std::string str;

using namespace std;

int main() {
    ll n;
    cin >> n;
    char pairs[n][2];
    for(ll i=0; i<n; i++) {
      cin >> pairs[i][0] >> pairs[i][1];
    }
    str x, y;
    cin >> x >> y;
    if(x.length() != y.length()) {
      cout << "NO" << endl;
      return 0;
    }
    for (ll i=0; i<n; i++) {
      str xReduced = "",
        yReduced = "";
      for (ll cur=0; cur<x.length(); cur++) {
        if(x[cur] == pairs[i][0] || x[cur] == pairs[i][1]) {
          xReduced += x[cur];
        }
        if(y[cur] == pairs[i][0] || y[cur] == pairs[i][1]) {
          yReduced += y[cur];
        }
      }
      if(xReduced != yReduced) {
        cout << "NO" << endl;
        return 0;
      }
    }
    cout << "YES" << endl;
    return 0;
}

Test details

Test 1

Verdict: ACCEPTED

input
5
a b
b c
c d
d e
...

correct output
YES

user output
YES

Test 2

Verdict: ACCEPTED

input
2
a b
b c
acbbaca
cabbaac

correct output
YES

user output
YES

Test 3

Verdict: ACCEPTED

input
2
a b
b c
acbbaca
baccaab

correct output
NO

user output
NO

Test 4

Verdict: ACCEPTED

input
10
d c
e b
f y
h q
...

correct output
YES

user output
YES

Test 5

Verdict: ACCEPTED

input
10
a i
a l
d a
g h
...

correct output
NO

user output
NO

Test 6

Verdict:

input
325
a b
a e
a f
a g
...

correct output
YES

user output
(empty)

Test 7

Verdict: ACCEPTED

input
325
a c
a e
a g
a h
...

correct output
NO

user output
NO

Test 8

Verdict: ACCEPTED

input
0
dlkinfmdyjaofxbccwhhbxzartqwdr...

correct output
YES

user output
YES

Test 9

Verdict: ACCEPTED

input
0
bxisdrdpgcsnnvhnfgimivzqpqjwqc...

correct output
NO

user output
NO

Test 10

Verdict: ACCEPTED

input
0
mrwduerojcguvxzmbomfsainvqehsl...

correct output
NO

user output
NO