Submission #464625

# Submission time Handle Problem Language Result Execution time Memory
464625 2021-08-13T14:31:22 Z ahmedfouadnew Zamjena (COCI18_zamjena) C++17
14 / 70
3 ms 1000 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
const int mod=1e9+7;
map<string,string>mp;
int n;
string s[5001];
string s2[5001];
signed main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>s[i];
    }
    for(int i=0;i<n;i++)
    {
        cin>>s2[i];
    }
    for(int i=0;i<n;i++)
    {
      bool isv=(s[i][0]<='z'&&s[i][0]>='a');
      bool isv2=(s2[i][0]<='z'&&s2[i][0]>='a');
      if(isv&&isv2)
      {
          s[i]=mp[s[i]];
          s2[i]=mp[s2[i]];
          if(s[i]==""||s2[i]=="") continue;
          if(s[i]!=s2[i])
          {
              puts("NE");
              return 0;
          }
          continue;
      }
      if(isv)
      {
          if(mp[s[i]]!=""&&mp[s[i]]!=s2[i])
          {
              puts("NE");
              return 0;
          }
          if(mp[s[i]]=="") mp[s[i]]=s2[i];
          continue;
      }
      if(isv2)
      {
          if(mp[s2[i]]!=""&&mp[s2[i]]!=s[i])
          {
              puts("NE");
              return 0;
          }
          if(mp[s2[i]]=="") mp[s2[i]]=s[i];
          continue;
      }
      if(s[i]!=s2[i])
      {
          puts("NE");
          return 0;
      }
    }
    for(int i=0;i<n/2;i++)
    {
        swap(s[i],s[n-i-1]);
        swap(s2[i],s2[n-i-1]);
    }
     for(int i=0;i<n;i++)
    {
      bool isv=(s[i][0]<='z'&&s[i][0]>='a');
      bool isv2=(s2[i][0]<='z'&&s2[i][0]>='a');
      if(isv&&isv2)
      {
          s[i]=mp[s[i]];
          s2[i]=mp[s2[i]];
          if(s[i]==""||s2[i]=="") continue;
          if(s[i]!=s2[i])
          {
              puts("NE");
              return 0;
          }
          continue;
      }
      if(isv)
      {
          if(mp[s[i]]!=""&&mp[s[i]]!=s2[i])
          {
              puts("NE");
              return 0;
          }
          if(mp[s[i]]=="") mp[s[i]]=s2[i];
          continue;
      }
      if(isv2)
      {
          if(mp[s2[i]]!=""&&mp[s2[i]]!=s[i])
          {
              puts("NE");
              return 0;
          }
          if(mp[s2[i]]=="") mp[s2[i]]=s[i];
          continue;
      }
      if(s[i]!=s2[i])
      {
          puts("NE");
          return 0;
      }
    }
    puts("DA");
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 588 KB Output is correct
2 Correct 1 ms 588 KB Output is correct
3 Correct 1 ms 588 KB Output is correct
4 Correct 1 ms 588 KB Output is correct
5 Correct 1 ms 588 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 588 KB Output is correct
2 Incorrect 1 ms 604 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 588 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 588 KB Output is correct
2 Incorrect 2 ms 588 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 1000 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -