# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
637646 | 2022-09-02T14:34:46 Z | NotLinux | Zamjena (COCI18_zamjena) | C++14 | 51 ms | 2636 KB |
/** * author: NotLinux * created: 02.09.2022 ~ 14:19:34 **/ #include <bits/stdc++.h> using namespace std; #define int long long #ifdef LOCAL #include "/home/notlinux/debug.h" #else #define debug(x...) void(37) #endif #define sos(x) dict[fond(x)]>0 // eğer dict de varsa 1 döndür int n; map < string , string > par; map < string , string > mpa; string fond(string str){ if(par[str] == str)return str; if(mpa.find(str) == mpa.end()){ par[str] = str; mpa[str] = 1; } par[str] = fond(par[str]); return par[str]; } void merge(string a , string b){ par[fond(a)] = fond(b); } bool nuum(string str){//eğer sayı ise 1 döndür for(auto itr : str)if(itr < '0' or itr > '9')return 0; return 1; } void solve(){ cin >> n; vector < string > a(n) ,b(n); map < string , int > dict; for(auto &inp : a)cin >> inp; for(auto &inp : b)cin >> inp; for(int i = 0;i<n;i++){ if(a[i] == b[i])continue; if(nuum(a[i]) and nuum(b[i])){ cout << "NE" << endl; return; } else if(nuum(a[i]) and nuum(b[i])==0){ if(sos(b[i])==0){ dict[fond(b[i])] = stoi(a[i]); } if(dict[fond(b[i])] != stoi(a[i])){ cout << "NE" << endl; return; } } else if(nuum(a[i])==0 and nuum(b[i])){ if(sos(a[i])==0){ dict[fond(a[i])] = stoi(b[i]); } if(dict[fond(a[i])] != stoi(b[i])){ cout << "NE" << endl; return; } } else { if(sos(a[i]) and sos(b[i]) and (dict[fond(a[i])] != dict[fond(b[i])])){ cout << "NE" << endl; return; } merge(a[i],b[i]); } } cout << "DA" << endl; } int32_t main(){ ios_base::sync_with_stdio(0);cin.tie(nullptr); int tt=1; //cin >> tt; while(tt--)solve(); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Incorrect | 1 ms | 212 KB | Output isn't correct |
7 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 468 KB | Output is correct |
2 | Correct | 3 ms | 456 KB | Output is correct |
3 | Correct | 13 ms | 1032 KB | Output is correct |
4 | Incorrect | 13 ms | 1236 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 51 ms | 2636 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |