#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void output(bool yes){yes ? cout << "Yes" << "\n" : cout << "No" << "\n";}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(0);
set <int> s;
char x;
int cur;
cin >> x;
cur = x - 'A';
s.insert(cur);
int n;
cin >> n;
for(int i = 0;i < n;i++){
char a,b;
cin >> a >> b;
int w = a - 'A';
int l = b - 'A';
if(l == cur){
cur = w;
s.insert(w);
}
}
cout << char(cur+65) << "\n";
cout << s.size() << "\n";
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
456 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |