Submission #721224

# Submission time Handle Problem Language Result Execution time Memory
721224 2023-04-10T14:12:04 Z vjudge1 Zamjena (COCI18_zamjena) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>

using namespace std;

bool is_str(string s){
   if(s[0] - '0' > 9){
      return true;
   }
   return false;
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);

    int n; cin >> n;

    vector<string> v1(n);
    map<string, string> mp;
    for(int i = 0; i < n; i++){
        cin >> v1[i];
        mp[v1[i]] = "-1";
    }
    vector<string> v2(n);
    for(int i = 0; i < n; i++){
        cin >> v2[i];
        mp[v2[i]] = "-1";
    }
    for(int i = 0; i < n; i++){
        if(!is_str(v1[i]) && !is_str(v2[i]) && v1[i] != v2[i]){
            cout << "NE" <<"\n";
            return 0;
        }
        if(is_str(v1[i]) && !is_str(v2[i])){
            if(mp[v1[i]] == "-1"){
               mp[v1[i]] = v2[i];
            }
        }
        if(!is_str(v1[i]) && is_str(v2[i])){
            if(mp[v2[i]] == "-1"){
               mp[v2[i]] = v1[i];
            }
        }
    }

    for(int i = 0; i < n; i++){
        if(mp[v1[i]] != "-1"){
            v1[i] = mp[v1[i]];
        }
    }
    for(int i = 0; i < n; i++){
        if(mp[v2[i]] != "-1"){
            v2[i] = mp[v2[i]];
        }
    }

    for(int i = 0; i < n; i++){
        if(!is_str(v1[i]) && !is_str(v2[i]) && v1[i] != v2[i]){
            cout "NE" <<"\n";
            return 0;
        }
        if(is_str(v1[i]) && is_str(v2[i])){
            v1[i] = "1";
            v2[i] = "1";
        }
        if(!is_str(v1[i]) && is_str(v2[i])){
            v2[i] = v1[i];
        }
        if(is_str(v1[i]) && !is_str(v2[i])){
            v1[i] = v2[i];
        }
    }
    for(int i = 0; i < n; i++){
        if(v1[i] != v2[i]){
            cout << "NE" <<"\n";
            return 0;
        }
    }
    /*
    for(int i = 0; i < n; i++){
        cout << v1[i] <<" ";
    }
    cout <<"\n";
    for(int i = 0; i < n; i++){
        cout << v2[i] <<" ";
    }
    cout <<"\n";
*/
    cout << "DA" <<"\n";



/*
3
3 1 2
3 1 x

4
4 5 iks ipsilon
1 iks 3 iks

5
x 3 x y 3
x y 2 z 3



*/

}

Compilation message

zamjena.cpp: In function 'int main()':
zamjena.cpp:59:17: error: expected ';' before string constant
   59 |             cout "NE" <<"\n";
      |                 ^~~~~
      |                 ;
zamjena.cpp:59:13: warning: statement has no effect [-Wunused-value]
   59 |             cout "NE" <<"\n";
      |             ^~~~