Submission #835326

#TimeUsernameProblemLanguageResultExecution timeMemory
835326EntityPlanttZamjena (COCI18_zamjena)C++14
0 / 70
6 ms4580 KiB
#include <iostream> #include <map> #include <set> using namespace std; int n, i; string arr[50000], x; map <string, int> m; map <string, set <string>> eq; inline const int v(const string &k) { return isdigit(k[0]) ? stoi(k) : m[k]; } inline const int s(const string &k, const int &i) { m[k] = i; string e; while (!eq[k].empty()) { e = *prev(eq[k].end()); eq[k].erase(prev(eq[k].end())); s(e, i); } } int main() { ios::sync_with_stdio(); cin.tie(0); cout.tie(0); cin >> n; for (i = 0; i < n; i++) cin >> arr[i]; for (i = 0; i < n; i++) { cin >> x; if (arr[i] == x); else if (v(arr[i]) && v(x)) { if (v(arr[i]) != v(x)) { cout << "NE"; return 0; } } else if (v(arr[i])) s(x, v(arr[i])); else if (v(x)) s(arr[i], v(x)); else { eq[arr[i]].insert(x); eq[x].insert(arr[i]); } } cout << "DA"; return 0; }

Compilation message (stderr)

zamjena.cpp: In function 'const int s(const string&, const int&)':
zamjena.cpp:20:1: warning: no return statement in function returning non-void [-Wreturn-type]
   20 | }
      | ^
#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...