#include <iostream>
using namespace std;
// int a[95];
int v[30], N, br;
char sol, x, y;
int main()
{
cin >> sol;
v[sol - 'A'] = 1;
cin >> N;
for (int i = 0; i < N; ++i){
cin >> x >> y;
if (y == sol){
sol = x;
v[x - 'A'] = 1;
}
}
cout << sol << endl;
for(int i = 0; i < 26; ++i)
br += v[i];
cout << br;
return 0;
}
/*
X
4
A X
B X
X A
D A
N
5
D A
N B
B A
C D
F A
*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
256 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
248 KB |
Output is correct |
9 |
Correct |
2 ms |
256 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |