Submission #81708

#TimeUsernameProblemLanguageResultExecution timeMemory
81708Mouhanad_HafezZamjena (COCI18_zamjena)C++11
14 / 70
27 ms2964 KiB
#include<bits/stdc++.h> using namespace std; bool ch(string s) { for (int i=0; i<s.size(); i++) { if (s[i]-'a'>=0&&s[i]-'a'<=25)return 0; } return 1; } int toint(string s) { int re=0; int p=1; for (int i=s.size()-1; i>=0; i--) { re+=((s[i]-'0')*p); p*=10; } return re; } map<string,int>mp,mp1; vector<pair<string,string>>v; int main() { int n; cin>>n; string arr1[n+6],arr2[n+6]; for (int i=0; i<n; i++)cin>>arr1[i]; for (int i=0; i<n; i++)cin>>arr2[i]; for (int i=0; i<n; i++) { string s1,s2; s1=arr1[i]; s2=arr2[i]; if (ch(s1)==1&&ch(s2)==1&&s1!=s2) { cout<<"NE"; return 0; } if (s1==s2)continue; if (ch(s1)==0&&ch(s2)==0) { int x1=mp[s1],x2=mp[s2]; int y1=mp1[s1],y2=mp1[s2]; //if (x1==x2)continue; if (x1!=x2&&y1==1&&y2==1) { cout<<"NE"; return 0; } if (x1!=x2&&y1==0&&y2==1) { mp[s1]=mp[s2]; mp1[s1]=1; mp1[s2]=1; continue; } if (x1!=x2&&y1==1&&y2==0) { mp[s2]=mp[s1]; mp1[s1]=1; mp1[s2]=1; continue; } if (y1==0&&y2==0) { v.push_back({s1,s2}); continue; } } if (ch(s1)==1&&ch(s2)==0) { if (mp1[s2]==1) { cout<<"NE"; return 0; } mp[s2]=toint(s1); mp1[s2]=1; } if (ch(s1)==0&&ch(s2)==1) { if (mp1[s1]==1) { cout<<"NE"; return 0; } mp[s1]=toint(s2); mp1[s1]=1; } } for (int i=0; i<v.size(); i++) { if (mp[v[i].first]!=mp[v[i].second]) { cout<<"NE"; return 0; } } cout<<"DA"; return 0; }

Compilation message (stderr)

zamjena.cpp: In function 'bool ch(std::__cxx11::string)':
zamjena.cpp:5:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i=0; i<s.size(); i++)
                   ~^~~~~~~~~
zamjena.cpp: In function 'int main()':
zamjena.cpp:95:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i=0; i<v.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...