Submission #464635

#TimeUsernameProblemLanguageResultExecution timeMemory
464635ahmedfouadnewZamjena (COCI18_zamjena)C++17
56 / 70
74 ms10956 KiB
#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 (stderr)

zamjena.cpp: In function 'long long int its(std::string)':
zamjena.cpp:17:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |     for(int i=0;i<sss.size();i++)
      |                 ~^~~~~~~~~~~
zamjena.cpp: In function 'int main()':
zamjena.cpp:73:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<std::__cxx11::basic_string<char>, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   73 |     for(int i=1;i<vv.size();i++)
      |                 ~^~~~~~~~~~
#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...