# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
470187 | 2021-09-03T08:16:11 Z | Karabasan | Zamjena (COCI18_zamjena) | C++17 | 20 ms | 4748 KB |
#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]; } 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
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 3404 KB | Output is correct |
2 | Incorrect | 2 ms | 3404 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 3404 KB | Output is correct |
2 | Incorrect | 2 ms | 3404 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 3352 KB | Output is correct |
2 | Correct | 2 ms | 3404 KB | Output is correct |
3 | Incorrect | 2 ms | 3404 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 3404 KB | Output is correct |
2 | Incorrect | 2 ms | 3404 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 3916 KB | Output is correct |
2 | Incorrect | 20 ms | 4748 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |