Submission #1013669

#TimeUsernameProblemLanguageResultExecution timeMemory
1013669SaladdZamjena (COCI18_zamjena)C++14
0 / 70
15 ms1936 KiB
#include <bits/stdc++.h> using namespace std; map <string,int> mp; int pa[1000000],arr[1000000],arr2[1000000],st[100000]; int root(int x) { if(pa[x]==x) return x; else return pa[x] = root(pa[x]); } int main() { cin.tie(0)->sync_with_stdio(0); int n; int idx=1; cin >> n; for (int i=1;i<=n;i++){ string str; int cnt=0; cin >> str; //cout << mp[str] << " ----\n"; if(mp[str]>0){ arr[i]=mp[str]; continue; } for (int j=0;j<str.size(),cnt==0;j++){ //cout << str[j] << "\n"; if(isalpha(str[j])){ arr[i]=idx; pa[idx]=idx; mp[str]=idx; st[idx++]=1; cnt=1; } else{ arr[i]=idx; pa[idx]=idx; mp[str]=idx; st[idx++]=0; cnt=1; } } } for (int i=1;i<=n;i++){ string str; int cnt=0; cin >> str; if(mp[str]>0){ arr2[i]=mp[str]; continue; } for (int j=0;j<str.size(),cnt==0;j++){ if(isalpha(str[j])){ arr2[i]=idx; pa[idx]=idx; mp[str]=idx; st[idx++]=1; cnt=1; } else{ arr2[i]=idx; pa[idx]=idx; mp[str]=idx; st[idx++]=0; cnt=1; } } } for(int i=1;i<=n;i++){ int a=arr[i]; int b=arr2[i]; if(root(a)!=root(b) && st[b]==1){ pa[root(b)]=root(a); st[b]=0; } if(root(a)!=root(b) && st[b]==0){ cout << "NE"; return 0; } } cout << "DA"; return 0; } /* 4 4 5 iks ipasdasd 1 iks 3 iks 3 5 iks ipasdasd iks 3 iks */

Compilation message (stderr)

zamjena.cpp: In function 'int main()':
zamjena.cpp:28:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |         for (int j=0;j<str.size(),cnt==0;j++){
      |                      ~^~~~~~~~~~~
zamjena.cpp:28:23: warning: value computed is not used [-Wunused-value]
zamjena.cpp:55:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |         for (int j=0;j<str.size(),cnt==0;j++){
      |                      ~^~~~~~~~~~~
zamjena.cpp:55:23: warning: value computed is not used [-Wunused-value]
#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...