답안 #472202

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
472202 2021-09-13T09:16:41 Z SaraMostafa Zamjena (COCI18_zamjena) C++14
28 / 70
38 ms 4760 KB
#include <bits/stdc++.h>
#include<unordered_map>
using namespace std;
#define ll long long
#define endl "\n"
#define Sara ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const long long mod=998244353;
const double PI=acos(-1);
int main()
{
    //freopen("input.in","r",stdin);
    Sara
    int n;
    cin>>n;
    vector<string>a(n),b(n);
    bool valid=1;
    for(int i=0; i<n; i++)
    {
        cin>>a[i];
    }
    for(int i=0; i<n; i++)
    {
        cin>>b[i];
    }
    map<string,string>mpd;
    for(int i=0; i<n; i++)
    {
        bool dia=isdigit(a[i][0]);

        bool dib=isdigit(b[i][0]);
        if(dia && dib)
            {
                
                if(a[i]!=b[i]){
                    valid=0;
                    break;
                }
                continue;
            }
        else if(!dia && !dib)
        {
            continue;
        }
        else
        {
            if(dia )
            {
                if(mpd[b[i]]=="" || mpd[b[i]]==a[i])
                    mpd[b[i]]=a[i];
                else
                {
                    valid=0;
                    break;
                }
            }
            else
            {

                if(mpd[a[i]]=="" || mpd[a[i]]==b[i])
                    mpd[a[i]]=b[i];
                else
                {
                    valid=0;
                    break;
                }
            }
        }
    }
    for(int i=0; i<n; i++)
    {
        bool dia=isdigit(a[i][0]);

        bool dib=isdigit(b[i][0]);
        if(dia || dib)
            continue;
        if(mpd[a[i]]=="" )
        {
            if(mpd[b[i]]=="")
                continue;
            else
                mpd[a[i]]=mpd[b[i]];
        }
        else if(mpd[b[i]]=="" )
        {
            if(mpd[a[i]]=="")
                continue;
            else
                mpd[b[i]]=mpd[a[i]];
        }
        else
        {
            if(mpd[a[i]]!=mpd[b[i]])
            {
                valid=0;
                break;
            }
        }
    }
    if(!valid)
        cout<<"NE"<<endl;
    else
        cout<<"DA"<<endl;



    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 0 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 1 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 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 0 ms 204 KB Output is correct
6 Incorrect 1 ms 204 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 2 ms 588 KB Output is correct
4 Incorrect 4 ms 716 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 1484 KB Output is correct
2 Correct 20 ms 3020 KB Output is correct
3 Incorrect 38 ms 4760 KB Output isn't correct
4 Halted 0 ms 0 KB -