Submission #167254

# Submission time Handle Problem Language Result Execution time Memory
167254 2019-12-07T04:25:30 Z mdn2002 Zamjena (COCI18_zamjena) C++14
28 / 70
63 ms 5100 KB
#include<bits/stdc++.h>
using namespace std;
int n;
vector<string>a,b;
map<string,string>m;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n;
    for(int i=0;i<n;i++)
    {
        string s;
        cin>>s;
        a.push_back(s);
    }
    for(int i=0;i<n;i++)
    {
        string s;
        cin>>s;
        b.push_back(s);
    }
    bool t=true;
    for(int i=0;i<n;i++)
    {
        string s=a[i],z=b[i];
        if('0'<=s[0]&&s[0]<='9')
        {
            if('0'<=z[0]&&z[0]<='9')
            {
                if(s!=z)
                {
                    t=false;
                    break;
                }
            }
            else m[z]=s;
        }
        else if('0'<=z[0]&&z[0]<='9')m[s]=z;
    }
    for(int i=0;i<n;i++)
    {
        string s=a[i],z=b[i];
        if(m[s].size()!=0&&m[z].size()!=0)
        {
            if(m[s]!=m[z])
            {
                t=false;
                break;
            }
        }
        if(m[s].size()==0&&m[z].size()!=0)
        {
            if('0'<=s[0]&&s[0]<='9')
            {
                if(m[z]!=s)
                {
                    t=false;
                    break;
                }
            }
            else m[s]=m[z];
        }
        if(m[s].size()!=0&&m[z].size()==0)
        {
            if('0'<=z[0]&&z[0]<='9')
            {
                if(m[s]!=z)
                {
                    t=false;
                    break;
                }
            }
            else m[z]=m[s];
        }
    }
    if(t==false)cout<<"NE";
    else cout<<"DA";
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 380 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Incorrect 2 ms 504 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 504 KB Output is correct
2 Correct 3 ms 504 KB Output is correct
3 Correct 5 ms 760 KB Output is correct
4 Incorrect 7 ms 888 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 16 ms 1648 KB Output is correct
2 Correct 49 ms 3216 KB Output is correct
3 Incorrect 63 ms 5100 KB Output isn't correct
4 Halted 0 ms 0 KB -