Submission #159691

#TimeUsernameProblemLanguageResultExecution timeMemory
159691sochoZamjena (COCI18_zamjena)C++14
70 / 70
326 ms16348 KiB
#include "bits/stdc++.h" using namespace std; map<string, vector<string> > adj; map<string, bool> vis; bool isn(string s) { char x = s[0]; if (x >= '0' && x <= '9') return true; return false; } int dfsw(string s, string last) { if (vis[s]) return 0; int count = isn(s); vis[s] = true; // cout << "dfs: " << s << endl; for (int i=0; i<adj[s].size(); i++) { string other = adj[s][i]; // cout << " > " << other << endl; if (other == last) continue; if (other == s) continue; if (vis[other]) continue; count += dfsw(other, s); } return count; } int main() { int n; cin >> n; string a1[n], a2[n]; for (int i=0; i<n; i++) cin >> a1[i]; for (int i=0; i<n; i++) cin >> a2[i]; for (int i=0; i<n; i++) { string a = a1[i], b = a2[i]; if (a == b) continue; adj[a].push_back(b); adj[b].push_back(a); } for (int i=0; i<n; i++) { string a = a1[i]; if (!vis[a]) { int re = dfsw(a, ""); // cout << "RES: " << a << ' ' << re << endl; if (re > 1) { cout << "NE" << endl; exit(0); } } } cout << "DA" << endl; exit(0); }

Compilation message (stderr)

zamjena.cpp: In function 'int dfsw(std::__cxx11::string, std::__cxx11::string)':
zamjena.cpp:18:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i=0; i<adj[s].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...