Submission #472406

# Submission time Handle Problem Language Result Execution time Memory
472406 2021-09-13T13:39:31 Z Ahmed_Solyman Zamjena (COCI18_zamjena) C++14
14 / 70
23 ms 1996 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

bool isNum(string s){
    return (s[0]>='1' && s[0]<='9');
}
int main()
{
    ll n;cin>>n;
    vector<string>a(n),b(n);
    for(auto &i:a)cin>>i;
    for(auto &i:b)cin>>i;
    bool v=1;
    map<string,string>mp;
    map<string,bool>vis,t;
    map<string,string>u;
    for(ll i=0;i<n;i++){
        if(vis[a[i]]){
            a[i]=mp[a[i]];
        }
        if(vis[b[i]]){
            b[i]=mp[b[i]];
        }
        if(isNum(a[i]) && isNum(b[i])){
            v&=(a[i]==b[i]);
        }
        else if(isNum(a[i])){
            vis[b[i]]=1;
            mp[b[i]]=a[i];
        }
        else if(isNum(b[i])){
            vis[a[i]]=1;
            
            mp[a[i]]=b[i];
        }
        else{
            if(mp[a[i]].empty()){
                mp[a[i]]=mp[b[i]];
            }
            else if(mp[a[i]].empty()){
                mp[b[i]]=mp[a[i]];
            }
            v&=(mp[a[i]]==mp[b[i]]);
        }
    }
    if(v){
        cout<<"DA";
    }
    else{
        cout<<"NE";
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 1 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Incorrect 1 ms 204 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 460 KB Output is correct
2 Correct 2 ms 332 KB Output is correct
3 Incorrect 6 ms 816 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 23 ms 1996 KB Output isn't correct
2 Halted 0 ms 0 KB -