Submission #377155

#TimeUsernameProblemLanguageResultExecution timeMemory
377155marat0210Elder (COCI19_elder)C++14
29 / 50
2 ms492 KiB
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >>s; int n; cin >>n; string res = s; vector <pair<string, string>> f; for (int i = 0; i < n; ++i) { string a, b; cin >>a>>b; f.push_back({a, b}); } int cnt = 1; for (int i = 0; i < n; ++i) { if (f[i].second == res) { res = f[i].first; cnt++; } } cout <<res<<endl; cout <<cnt<<endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...