Submission #254836

#TimeUsernameProblemLanguageResultExecution timeMemory
254836MolukhyyehZamjena (COCI18_zamjena)C++14
42 / 70
75 ms15224 KiB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) x.begin(),x.end() 

int const N = 200001;
int n, a[N], b[N];
string x[N], y[N];
map<string, int> mp;

int main(){
    scanf("%d", &n);
    for(int i = 0; i<n; ++i){
        cin >> x[i];
        if(x[i][0]-'0' >= 0 && x[i][0]-'0' <= 9){
            stringstream ss; 
            ss << x[i];
            ss >> a[i];
        }
        else a[i] = -1;
    }
    for(int i = 0; i<n; ++i){
        cin >> y[i];
        if(y[i][0]-'0' >= 0 && y[i][0]-'0' <= 9){
            stringstream ss; 
            ss << y[i];
            ss >> b[i];
        }
        else b[i] = -1;
    }
    for(int i = 0; i<n; ++i){
        if(a[i] == -1 && mp[x[i]])a[i] = mp[x[i]];
        if(b[i] == -1 && mp[y[i]])b[i] = mp[y[i]];
        if(~a[i]){
            if(b[i] == -1)mp[y[i]] = a[i], b[i] = a[i];
        }
        if(~b[i]){
           if(a[i] == -1)mp[x[i]] = b[i], a[i] = b[i];
        }
        if(a[i] != b[i])return puts("NE"), 0;
    }
    for(int i = 0; i<n; ++i){
       if(a[i] == -1 && mp[x[i]])a[i] = mp[x[i]];
        if(b[i] == -1 && mp[y[i]])b[i] = mp[y[i]];
        if(~a[i]){
            if(b[i] == -1)mp[y[i]] = a[i], b[i] = a[i];
        }
        if(~b[i]){
           if(a[i] == -1)mp[x[i]] = b[i], a[i] = b[i];
        }
        if(a[i] != b[i])return puts("NE"), 0;  
    }
    puts("DA");
}

Compilation message (stderr)

zamjena.cpp: In function 'int main()':
zamjena.cpp:12:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...