답안 #119259

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
119259 2019-06-20T19:07:36 Z Rubanov Elder (COCI19_elder) C++17
50 / 50
3 ms 384 KB
#include <bits/stdc++.h>
#define ll long long
#define f first
#define s second

using namespace std;

int main() {
  ios::sync_with_stdio(0); cin.tie(0);
  char a;
  int n,cnt=1;
  cin>>a>>n;
  bool us[260]={};
  us[a]=1;
  while (n--) {
    char z1,z2;
    cin>>z1>>z2;
    if (a==z2) {
      a = z1;
      if (!us[a])
        cnt++;
      us[a]=1;
    }
  }
  cout<<a<<'\n'<<cnt;
  return 0;
}

Compilation message

elder.cpp: In function 'int main()':
elder.cpp:14:7: warning: array subscript has type 'char' [-Wchar-subscripts]
   us[a]=1;
       ^
elder.cpp:20:16: warning: array subscript has type 'char' [-Wchar-subscripts]
       if (!us[a])
                ^
elder.cpp:22:11: warning: array subscript has type 'char' [-Wchar-subscripts]
       us[a]=1;
           ^
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 3 ms 356 KB Output is correct