Submission #259791

#TimeUsernameProblemLanguageResultExecution timeMemory
259791itiamZamjena (COCI18_zamjena)C++11
70 / 70
351 ms16248 KiB
#include <bits/stdc++.h> using namespace std; #define pb push_back int n,cnt; string a[50007],b[50007]; map< string, vector<string>> v; map< string, int> bio; void dfs(string x){ if (bio[x]==1) return; bio[x]=1; if (isdigit(x[0])){ cnt++; } for (int i=0;i<v[x].size();i++){ dfs(v[x][i]); } } void provjeri(string x){ if (bio[x]==1) return; cnt=0; dfs(x); if (cnt>1){ cout << "NE"; exit(0); } } int main(){ cin >>n; for (int i=0;i<n;i++) cin >> a[i]; for (int i=0;i<n;i++) cin >> b[i]; for (int i=0;i<n;i++){ v[a[i]].pb(b[i]); v[b[i]].pb(a[i]); } for (int i=0;i<n;i++){ provjeri(a[i]); provjeri(b[i]); } cout << "DA"; return 0; }

Compilation message (stderr)

zamjena.cpp: In function 'void dfs(std::__cxx11::string)':
zamjena.cpp:15:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i=0;i<v[x].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...