Submission #472169

# Submission time Handle Problem Language Result Execution time Memory
472169 2021-09-13T08:39:50 Z AbdoMo Zamjena (COCI18_zamjena) C++17
28 / 70
47 ms 2620 KB
#include<bits/stdc++.h>
#define int long long
#define ll long long
#define pb push_back
const int mod = 1e9+7;
using namespace std;
bool comp(pair<int,int>&a ,pair<int,int>&b)
{
    if(a.first==b.first)
    {
        return a.second>b.second;
    }
    return a.first<b.first;

}
void solve()
{
    int n;
    cin>>n;
    vector<string>v(n),v2(n);
    map<string,int>mp;
    for(int i=0;i<n;i++)
    {
        cin>>v[i];
        mp[v[i]]=0;
    }
    for(int i=0;i<n;i++)
    {
        cin>>v2[i];
        mp[v2[i]]=0;
    }

    for(int i=0;i<n;i++)
    {
        char x=v[i][0];
        char y=v2[i][0];
        if(isdigit(x) && isdigit(y))
        {
            if(v[i]!=v2[i])
            {
                cout<<"NE"<<endl;
                return;
            }
            continue;
        }
        else if(islower(y) && isdigit(x))
        {
            if(mp[v2[i]]==0)
            {
                mp[v2[i]]=stoi(v[i]);
                v2[i]=v[i];
            }
            else
            {
                if(mp[v2[i]]!=stoi(v[i]))
                {
                    cout<<"NE"<<endl;
                    return;
                }
                else
                {
                    v2[i]=v[i];
                }
            }
        }
        else if(islower(x) && isdigit(y))
        {
            if(mp[v[i]]==0)
            {
                mp[v[i]]=stoi(v2[i]);
                v[i]=v2[i];
            }
            else
            {
                if(mp[v[i]]!=stoi(v2[i]))
                {
                    cout<<"NE"<<endl;
                    return;
                }
                else
                {
                    v[i]=v2[i];
                }
            }
        }
        else
        {
            char x=v[i][0];
            char y=v2[i][0];
            if(mp[v2[i]]==0 && mp[v[i]]!=0)
            {
                v2[i]=to_string(mp[v[i]]);
                v[i]=to_string(mp[v[i]]);
            }
            else if(mp[v2[i]]!=0 && mp[v[i]]==0)
            {
                v[i]=to_string(mp[v2[i]]);
                v2[i]=to_string(mp[v2[i]]);
            }
            else if(mp[v2[i]]!=0 && mp[v[i]]!=0)
            {
                v[i]=to_string(mp[v[i]]);
                v2[i]=to_string(mp[v2[i]]);
            }
        }

    }
    for(int i=0;i<n;i++)
    {
        //cout<<v[i]<<" ";
        char x=v[i][0];
        char y=v2[i][0];
        if(islower(x) && islower(y))
        {
            if(mp[v2[i]]==0 && mp[v[i]]!=0)
            {
                v2[i]=to_string(mp[v[i]]);
                v[i]=to_string(mp[v[i]]);
            }
            else if(mp[v2[i]]!=0 && mp[v[i]]==0)
            {
                v[i]=to_string(mp[v2[i]]);
                v2[i]=to_string(mp[v2[i]]);
            }
            else if(mp[v2[i]]!=0 && mp[v[i]]!=0)
            {
                v[i]=to_string(mp[v[i]]);
                v2[i]=to_string(mp[v2[i]]);
            }
            else
            {
                mp[v[i]]=1;
                mp[v2[i]]=1;
                v[i]="1";
                v2[i]="1";
            }
        }
        if(isdigit(x) && isdigit(y))
        {
            if(v[i]!=v2[i])
            {
                cout<<"NE"<<endl;
                return;
            }
            continue;
        }

    }
    for(int i=0;i<n;i++)
    {
        //cout<<v[i]<<" ";
        char x=v[i][0];
        char y=v2[i][0];
        if(isdigit(x) && isdigit(y))
        {
            if(v[i]!=v2[i])
            {
                cout<<"NE"<<endl;
                return;
            }
            continue;
        }

    }
    cout<<"DA"<<endl;

}
int32_t main(){
	int t=1;
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //cin>>t;
	while(t--){solve();}
	return 0;
}

Compilation message

zamjena.cpp: In function 'void solve()':
zamjena.cpp:88:18: warning: unused variable 'x' [-Wunused-variable]
   88 |             char x=v[i][0];
      |                  ^
zamjena.cpp:89:18: warning: unused variable 'y' [-Wunused-variable]
   89 |             char y=v2[i][0];
      |                  ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 23 ms 1396 KB Output is correct
2 Incorrect 47 ms 2620 KB Output isn't correct
3 Halted 0 ms 0 KB -