#include<bits/stdc++.h>
using namespace std;
bool pernah[26];
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
char now;
cin >> now;
pernah[now-'A']=true;
int n;
cin >> n;
for(int i=1;i<=n;i++){
char win,lose;
cin >> win >> lose;
if(lose==now){
now=win;
pernah[now-'A']=true;
}
}
int ans=0;
for(int i=0;i<26;i++){
if(pernah[i])ans++;
}
cout << now << endl;
cout << ans << endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
292 KB |
Output is correct |
4 |
Correct |
2 ms |
376 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 |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |