제출 #637646

#제출 시각아이디문제언어결과실행 시간메모리
637646NotLinuxZamjena (COCI18_zamjena)C++14
28 / 70
51 ms2636 KiB
/** * 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(); }

컴파일 시 표준 에러 (stderr) 메시지

zamjena.cpp: In function 'void solve()':
zamjena.cpp:13:29: warning: suggest parentheses around comparison in operand of '==' [-Wparentheses]
   13 | #define sos(x) dict[fond(x)]>0 // eğer dict de varsa 1 döndür
zamjena.cpp:46:16: note: in expansion of macro 'sos'
   46 |             if(sos(b[i])==0){
      |                ^~~
zamjena.cpp:13:29: warning: suggest parentheses around comparison in operand of '==' [-Wparentheses]
   13 | #define sos(x) dict[fond(x)]>0 // eğer dict de varsa 1 döndür
zamjena.cpp:55:16: note: in expansion of macro 'sos'
   55 |             if(sos(a[i])==0){
      |                ^~~
#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...