Submission #470188

#TimeUsernameProblemLanguageResultExecution timeMemory
470188KarabasanZamjena (COCI18_zamjena)C++17
0 / 70
19 ms4592 KiB
#include <bits/stdc++.h> #define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); #define forcin for(int i=0;i<n;i++) scanf("%d",&dizi[i]); #define forcout for(int i=0;i<n;i++) printf("%d ",dizi[i]); #define ll long long using namespace std; int n,t; string dizi[50005]; string dizi1[50005]; int diziyan[50005]; int dizi1yan[50005]; map<string,int> mp; int main() { fast; scanf("%d",&n); for(int i=0;i<n;i++) cin>>dizi[i]; for(int i=0;i<n;i++) cin>>dizi1[i]; for(int i=0;i<n;i++) { if(dizi[i][0]=='0'||dizi[i][0]=='1'||dizi[i][0]=='2'||dizi[i][0]=='3'||dizi[i][0]=='4'||dizi[i][0]=='5'||dizi[i][0]=='6'||dizi[i][0]=='7'||dizi[i][0]=='8'||dizi[i][0]=='9') { diziyan[i]=stoi(dizi[i]); } } for(int i=0;i<n;i++) { if(dizi1[i][0]=='0'||dizi1[i][0]=='1'||dizi1[i][0]=='2'||dizi1[i][0]=='3'||dizi1[i][0]=='4'||dizi1[i][0]=='5'||dizi1[i][0]=='6'||dizi1[i][0]=='7'||dizi1[i][0]=='8'||dizi1[i][0]=='9') { dizi1yan[i]=stoi(dizi1[i]); } } for(int i=0;i<n;i++) { if(diziyan[i]!=0&&dizi1yan[i]==0) mp[dizi1[i]]=diziyan[i]; else if(diziyan[i]==0&&dizi1yan[i]!=0) mp[dizi[i]]=dizi1yan[i]; else if(diziyan[i]==0&&dizi1yan[i]==0) { if(mp[dizi[i]]==0&&mp[dizi1[i]]==0) continue; else if (mp[dizi[i]]==0&&mp[dizi1[i]]!=0) { mp[dizi[i]]=mp[dizi1[i]]; } else if(mp[dizi[i]]!=0&&mp[dizi1[i]]==0) mp[dizi1[i]]=mp[dizi[i]]; else if(mp[dizi[i]]!=mp[dizi1[i]]) { printf("NE"); return 0; } } else if(diziyan[i]!=0&&dizi1yan[i]!=0) { if(diziyan[i]!=dizi1yan[i]) { printf("NE"); return 0; } } } for(int i=0;i<n;i++) { if(diziyan[i]!=0&&dizi1yan[i]!=0) { if(diziyan[i]!=dizi1yan[i]) { printf("NE"); return 0; } } else if(diziyan[i]!=0&&dizi1yan[i]==0) { if(mp[dizi1[i]]!=diziyan[i]) { printf("NE"); return 0; } } else if(diziyan[i]==0&&dizi1yan[i]!=0) { if(mp[dizi[i]]!=dizi1yan[i]) { printf("NE"); return 0; } } else if(diziyan[i]==0&&dizi1yan[i]==0) { if(mp[dizi[i]]==0&&mp[dizi1[i]]==0) continue; else if (mp[dizi[i]]==0&&mp[dizi1[i]]!=0) { mp[dizi[i]]=mp[dizi1[i]]; } else if(mp[dizi[i]]!=0&&mp[dizi1[i]]==0) mp[dizi1[i]]=mp[dizi[i]]; else if(mp[dizi[i]]!=mp[dizi1[i]]) { printf("NE"); return 0; } } } printf("DA"); return 0; }

Compilation message (stderr)

zamjena.cpp: In function 'int main()':
zamjena.cpp:17:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |     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...