# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
313913 | 2020-10-17T09:43:12 Z | phathnv | Elder (COCI19_elder) | C++11 | 1 ms | 368 KB |
#include <bits/stdc++.h> #define mp make_pair #define X first #define Y second #define taskname "ELDER" using namespace std; typedef long long ll; typedef pair <int, int> ii; char s; int n; bool d[26]; void readInput(){ cin >> s >> n; } void solve(){ int cnt = 1; int cur = s - 'A'; d[cur] = 1; for(int i = 1; i <= n; i++){ char a, b; cin >> a >> b; a -= 'A'; b -= 'A'; if (b != cur) continue; cur = a; if (!d[cur]) cnt++; d[cur] = 1; } cout << (char) (cur + 'A') << '\n' << cnt; } int main(){ if (fopen(taskname".inp", "r")){ freopen(taskname".inp", "r", stdin); freopen(taskname".out", "w", stdout); } readInput(); solve(); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 256 KB | Output is correct |
2 | Correct | 1 ms | 256 KB | Output is correct |
3 | Correct | 1 ms | 256 KB | Output is correct |
4 | Correct | 1 ms | 368 KB | Output is correct |
5 | Correct | 1 ms | 256 KB | Output is correct |
6 | Correct | 0 ms | 256 KB | Output is correct |
7 | Correct | 0 ms | 256 KB | Output is correct |
8 | Correct | 1 ms | 256 KB | Output is correct |
9 | Correct | 0 ms | 256 KB | Output is correct |
10 | Correct | 1 ms | 256 KB | Output is correct |