# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
464635 | 2021-08-13T14:49:39 Z | ahmedfouadnew | Zamjena (COCI18_zamjena) | C++17 | 74 ms | 10956 KB |
#include<bits/stdc++.h> using namespace std; #define int long long #define pb push_back const int mod=1e9+7; map<string,string>mp; int n; string s[50001]; string s2[50001]; int sz[100001]; int par[100001]; int num[100001]; vector<pair<string,int> >vv; int its(string sss) { int ret=0; for(int i=0;i<sss.size();i++) { ret*=10; ret+=sss[i]-'0'; } return ret; } int findp(int u) { if(par[u]==u) return u; return par[u]=findp(par[u]); } void join(int u,int v) { u=findp(u); v=findp(v); if(u==v) return; if(num[u]&&num[v]&&(num[u]!=num[v])) { puts("NE"); exit(0); } if(sz[u]<sz[v]) swap(u,v); par[v]=u; sz[u]+=sz[v]; num[u]=num[u]|num[v]; return; } signed main() { int n; cin>>n; for(int i=0;i<n;i++) { cin>>s[i]; sz[i]=1; par[i]=i; if(s[i][0]<='9'&&s[i][0]>='1') num[i]=its(s[i]); } for(int i=0;i<n;i++) { cin>>s2[i]; par[n+i]=n+i; sz[n+i]=1; if(s2[i][0]<='9'&&s2[i][0]>='1') num[n+i]=its(s2[i]); } for(int i=0;i<n;i++) { vv.pb({s[i],i}); vv.pb({s2[i],n+i}); join(i,i+n); } sort(vv.begin(),vv.end()); for(int i=1;i<vv.size();i++) { if(vv[i].first[0]<='9'&&vv[i].first[0]>='1') continue; if(vv[i].first==vv[i-1].first) { join(vv[i].second,vv[i-1].second); } } puts("DA"); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 3404 KB | Output is correct |
2 | Correct | 2 ms | 3404 KB | Output is correct |
3 | Correct | 2 ms | 3404 KB | Output is correct |
4 | Correct | 2 ms | 3404 KB | Output is correct |
5 | Correct | 2 ms | 3404 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 3404 KB | Output is correct |
2 | Correct | 2 ms | 3404 KB | Output is correct |
3 | Correct | 2 ms | 3404 KB | Output is correct |
4 | Correct | 2 ms | 3404 KB | Output is correct |
5 | Correct | 2 ms | 3404 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 3404 KB | Output is correct |
2 | Correct | 2 ms | 3404 KB | Output is correct |
3 | Correct | 2 ms | 3404 KB | Output is correct |
4 | Incorrect | 2 ms | 3404 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 3532 KB | Output is correct |
2 | Correct | 4 ms | 3532 KB | Output is correct |
3 | Correct | 5 ms | 4012 KB | Output is correct |
4 | Correct | 5 ms | 4012 KB | Output is correct |
5 | Correct | 6 ms | 4012 KB | Output is correct |
6 | Correct | 6 ms | 4012 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 13 ms | 5248 KB | Output is correct |
2 | Correct | 26 ms | 6996 KB | Output is correct |
3 | Correct | 40 ms | 7348 KB | Output is correct |
4 | Correct | 55 ms | 10484 KB | Output is correct |
5 | Correct | 74 ms | 10620 KB | Output is correct |
6 | Correct | 65 ms | 10956 KB | Output is correct |