답안 #254836

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
254836 2020-07-30T17:34:56 Z Molukhyyeh Zamjena (COCI18_zamjena) C++14
42 / 70
75 ms 15224 KB
#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

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);
     ~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 12800 KB Output is correct
2 Correct 9 ms 12800 KB Output is correct
3 Correct 7 ms 12800 KB Output is correct
4 Correct 7 ms 12800 KB Output is correct
5 Correct 8 ms 12800 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 12800 KB Output is correct
2 Correct 11 ms 12800 KB Output is correct
3 Correct 9 ms 12800 KB Output is correct
4 Correct 8 ms 12800 KB Output is correct
5 Correct 8 ms 12800 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 12800 KB Output is correct
2 Correct 8 ms 12928 KB Output is correct
3 Correct 8 ms 12800 KB Output is correct
4 Correct 8 ms 12800 KB Output is correct
5 Correct 7 ms 12800 KB Output is correct
6 Incorrect 8 ms 12800 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 12928 KB Output is correct
2 Correct 9 ms 12928 KB Output is correct
3 Correct 14 ms 13056 KB Output is correct
4 Correct 13 ms 13056 KB Output is correct
5 Correct 18 ms 13056 KB Output is correct
6 Correct 11 ms 13056 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 33 ms 13432 KB Output is correct
2 Correct 52 ms 14200 KB Output is correct
3 Incorrect 75 ms 15224 KB Output isn't correct
4 Halted 0 ms 0 KB -