# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
464620 | 2021-08-13T14:25:11 Z | aihay | Zamjena (COCI18_zamjena) | C++14 | 24 ms | 32336 KB |
#pragma GCC optimize ("O3") #pragma GCC optimize ("unroll-loops") #pragma GCC optimize("-Ofast") #include <bits/stdc++.h> using namespace std; typedef int in; #define int long long #define f first #define s second #define pb push_back #define pp push #define double long double #define ceil(x,y) (x/y)+(x%y!=0)*((double)(1.0*x/y)<0?0:1) #define floor(x,y) (x/y)+(x%y!=0)*((double)(1.0a*x/y)<0?-1:0) const int MAX=1e7; const int MOD=1e9+7; const int MAAX=1e18; int arr[500010],arr2[500010]; string s[500010],s2[500010]; map<string,int> mp; in main(){ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); int tc=1; //cin>>tc; while(tc--){ int n; cin>>n; for(int i=0;i<n;i++){ cin>>s[i]; if(s[i][0]>='0'&&s[i][0]<='9'){ for(int j=0;j<s[i].size();j++){ arr[i]*=10; arr[i]+=s[i][j]-'0'; } s[i]=""; } else{ arr[i]=-1; } } for(int i=0;i<n;i++){ cin>>s2[i]; if(s2[i][0]>='0'&&s2[i][0]<='9'){ for(int j=0;j<s2[i].size();j++){ arr2[i]*=10; arr2[i]+=s2[i][j]-'0'; } s2[i]=""; } else{ arr2[i]=-1; } if(~arr2[i]&&~arr[i]) continue; if(~arr[i]){ arr2[i]=arr[i]; mp[s2[i]]=arr[i]; continue; } if(~arr2[i]){ arr[i]=arr2[i]; mp[s[i]]=arr[i]; continue; } } for(int i=0;i<n;i++){ if(arr2[i]==-1&&arr[i]==-1){ if(mp[s[i]]&&mp[s2[i]]==0){ mp[s2[i]]=mp[s[i]]; } else if(mp[s2[i]]&&mp[s[i]]==0) mp[s[i]]=mp[s2[i]]; else if(mp[s[i]]==0) mp[s[i]]=mp[s2[i]]=1; arr[i]=mp[s[i]]; arr2[i]=mp[s2[i]]; } if(arr[i]!=arr2[i]||arr[i]==-1||arr2[i]==-1){ cout<<"NE\n"; return 0; } } cout<<"DA\n"; } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 18 ms | 31564 KB | Output is correct |
2 | Correct | 18 ms | 31564 KB | Output is correct |
3 | Correct | 18 ms | 31564 KB | Output is correct |
4 | Correct | 18 ms | 31636 KB | Output is correct |
5 | Correct | 18 ms | 31556 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 18 ms | 31576 KB | Output is correct |
2 | Correct | 18 ms | 31564 KB | Output is correct |
3 | Correct | 18 ms | 31640 KB | Output is correct |
4 | Correct | 17 ms | 31564 KB | Output is correct |
5 | Correct | 18 ms | 31636 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 18 ms | 31588 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 20 ms | 31564 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 24 ms | 31976 KB | Output is correct |
2 | Incorrect | 24 ms | 32336 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |