답안 #472373

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
472373 2021-09-13T12:34:31 Z MamdouhN Zamjena (COCI18_zamjena) C++17
28 / 70
52 ms 39208 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"

int n;
map<string,string>idk;
string row1[600000],row2[600000];

main()
{



    cin>>n;
    for(int i=0;i<n;i++)cin>>row1[i];
    for(int i=0;i<n;i++)cin>>row2[i];

    for(int i=0;i<n;i++)
    {
        bool is_var1 = (row1[i][0]>='a'&&row1[i][0]<='z');
        bool is_var2 = (row2[i][0]>='a'&&row2[i][0]<='z');
        if(is_var1&&is_var2)continue;
        if(is_var1)
        {
            if(idk[row1[i]]!="")
            {
                row1[i]=idk[row1[i]];
                continue;
            }
            idk[row1[i]]=row2[i];
            row1[i]=row2[i];
        }
        if(is_var2)
        {
            if(idk[row2[i]]!="")
            {
                row2[i]=idk[row2[i]];
                continue;
            }
            idk[row2[i]]=row1[i];
            row2[i]=row1[i];
        }
    }
    //cout<<"--------------------"<<endl;
    //for(auto v:row1)cout<<v<<" ";
    //cout<<endl;
    //for(auto v:row2)cout<<v<<" ";
    //cout<<endl;
    for(int i=0;i<n;i++)
    {
        bool is_var1 = (row1[i][0]>='a'&&row1[i][0]<='z');
        bool is_var2 = (row2[i][0]>='a'&&row2[i][0]<='z');
        if(is_var1&&is_var2)
        {
            bool has_value1 = (idk[row1[i]]!="");
            bool has_value2 = (idk[row2[i]]!="");
            if(!has_value1&&!has_value2)
            {
                idk[row1[i]]="1";
                idk[row2[i]]="1";
            }
            else if(!has_value1)idk[row1[i]]=idk[row2[i]];
            else if(!has_value2)idk[row2[i]]=idk[row1[i]];
            row1[i]=idk[row1[i]];
            row2[i]=idk[row2[i]];
        }
    }
    //cout<<"--------------------"<<endl;
    //for(auto v:row1)cout<<v<<" ";
    //cout<<endl;
    //for(auto v:row2)cout<<v<<" ";
    //cout<<endl;
    bool cando=1;

    for(int i=0;i<n;i++)
    {
        if(row1[i]!=row2[i])cando=0;
    }
    cout<<(cando?"DA":"NE")<<endl;


}

Compilation message

zamjena.cpp:10:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   10 | main()
      | ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 22 ms 37836 KB Output is correct
2 Correct 20 ms 37868 KB Output is correct
3 Correct 20 ms 37840 KB Output is correct
4 Correct 20 ms 37812 KB Output is correct
5 Correct 20 ms 37868 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 20 ms 37752 KB Output is correct
2 Correct 20 ms 37836 KB Output is correct
3 Correct 20 ms 37748 KB Output is correct
4 Correct 20 ms 37788 KB Output is correct
5 Correct 20 ms 37776 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 21 ms 37768 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 25 ms 37836 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 37 ms 38492 KB Output is correct
2 Incorrect 52 ms 39208 KB Output isn't correct
3 Halted 0 ms 0 KB -