Submission #151413

#TimeUsernameProblemLanguageResultExecution timeMemory
151413phillipZamjena (COCI18_zamjena)C++14
70 / 70
230 ms17900 KiB
#include <bits/stdc++.h> using namespace std; vector<string>s; map<string,int>name; int val[100009],vis[100009]; vector<int>v[100009]; void dfs(int x) { if(vis[x])return; vis[x]=1; for(int i=0;i<v[x].size();i++) { int y=v[x][i]; if(val[x]!=val[y]&&val[y]!=-1) { cout<<"NE"; exit(0); } val[y]=val[x]; dfs(y); } } int mapit(string s) { if(s.size()<=3) { int x=0,ml=1; for(int i=s.size()-1;i>=0;i--) { if(s[i]-'0'>9) { return -1; } x+=(s[i]-'0')*ml; ml*=10; } return x; } return -1; } int n; string a1[100090],a2[100009]; int main() { cin>>n; for(int i=0;i<n;i++) { cin>>a1[i]; s.push_back(a1[i]); } for(int i=0;i<n;i++) { cin>>a2[i]; s.push_back(a2[i]); } int nn; for(int i=0,j=0;i<s.size();i++) { if(name[s[i]])continue; name[s[i]]=j; val[j]=mapit(s[i]); j++; nn=j; } for(int i=0;i<n;i++) { int x=name[a1[i]],y=name[a2[i]]; v[x].push_back(y); v[y].push_back(x); } for(int i=0;i<nn;i++) { if(val[i]==-1)continue; dfs(i); } cout<<"DA"; }

Compilation message (stderr)

zamjena.cpp: In function 'void dfs(int)':
zamjena.cpp:12:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0;i<v[x].size();i++)
                 ~^~~~~~~~~~~~
zamjena.cpp: In function 'int main()':
zamjena.cpp:58:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0,j=0;i<s.size();i++)
                     ~^~~~~~~~~
zamjena.cpp:57:9: warning: 'nn' may be used uninitialized in this function [-Wmaybe-uninitialized]
     int nn;
         ^~
#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...