답안 #472314

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
472314 2021-09-13T11:33:43 Z Ahmed_Solyman Zamjena (COCI18_zamjena) C++14
56 / 70
148 ms 16068 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

bool isNum(string s){
    if(s.size()==1)return (s[0]>='0' && s[0]<='9');
    else return (s[0]>='1' && s[0]<='9');
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);      cout.tie(0);
    ll n;cin>>n;
    vector<string>a(n),b(n);
    for(auto &i:a)cin>>i;
    for(auto &i:b)cin>>i;
    bool v=1;
    map<string,string>mp;
    map<string,bool>vis;
    map<string,vector<string>>u;
    for(ll i=0;i<n;i++){
        if(vis[a[i]]){
            a[i]=mp[a[i]];
        }
        if(vis[b[i]]){
            b[i]=mp[b[i]];
        }
        if(isNum(a[i]) && isNum(b[i])){
            v&=(a[i]==b[i]);
        }
        else if(isNum(a[i])){
            for(auto j:u[b[i]]){
                if(vis[j]){
                    v&=(mp[j] == a[i]);
                }
                else{
                    vis[j]=1;
                    mp[j]=a[i];
                }
            }
            vis[b[i]]=1;
            mp[b[i]]=a[i];
        }
        else if(isNum(b[i])){
            for(auto j:u[a[i]]){
                if(vis[j]){
                    v&=(mp[j] == b[i]);
                }
                else{
                    vis[j]=1;
                    mp[j]=b[i];
                }
            }
            vis[a[i]]=1;
            mp[a[i]]=b[i];
        }
        else{
            u[a[i]].push_back(b[i]);
            u[b[i]].push_back(a[i]);
        }
    }
    if(v){
        cout<<"DA";
    }
    else{
        cout<<"NE";
    }
    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 1 ms 204 KB Output is correct
5 Correct 1 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 1 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 1 ms 204 KB Output is correct
4 Incorrect 1 ms 204 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 572 KB Output is correct
2 Correct 2 ms 460 KB Output is correct
3 Correct 6 ms 1160 KB Output is correct
4 Correct 5 ms 1228 KB Output is correct
5 Correct 6 ms 1228 KB Output is correct
6 Correct 5 ms 972 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 18 ms 3148 KB Output is correct
2 Correct 40 ms 5968 KB Output is correct
3 Correct 71 ms 9628 KB Output is correct
4 Correct 105 ms 11312 KB Output is correct
5 Correct 148 ms 16068 KB Output is correct
6 Correct 115 ms 11348 KB Output is correct