#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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
1 ms |
364 KB |
Output is partially correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Partially correct |
1 ms |
364 KB |
Output is partially correct |
4 |
Partially correct |
1 ms |
364 KB |
Output is partially correct |
5 |
Partially correct |
1 ms |
364 KB |
Output is partially correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Partially correct |
1 ms |
364 KB |
Output is partially correct |
8 |
Correct |
2 ms |
492 KB |
Output is correct |
9 |
Partially correct |
1 ms |
364 KB |
Output is partially correct |
10 |
Partially correct |
1 ms |
364 KB |
Output is partially correct |