Submission #165621

# Submission time Handle Problem Language Result Execution time Memory
165621 2019-11-27T20:23:10 Z itiam Elder (COCI19_elder) C++11
50 / 50
2 ms 384 KB
#include <iostream>
#include <algorithm>

using namespace std;

int L[30];
int main(){
    char bla='E';
    string vla,X,Y;
    int N,br=1;
    cin >> vla >> N;
    //char pr_vla=(char)vla[0];
    L[(int)((char)vla[0])-65]=1;
    //cout << (int)((char)vla[0])-65;


    for (int i=0;i<N;i++){
        cin >> X >> Y;
        if (Y==vla){
            vla=X;
            if (L[(int)((char)vla[0])-65]!=1){
                L[(int)((char)vla[0])-65]=1;
                br+=1;
            }
        }
    }
    cout << vla << "\n";
    cout << br;

    /*string a[]={"a","c","b","h","d",},x="c",y="e";
    bool exists = find(begin(a), end(a),y) != end(a);
    cout << exists;
    */
    return 0;
}

Compilation message

elder.cpp: In function 'int main()':
elder.cpp:8:10: warning: unused variable 'bla' [-Wunused-variable]
     char bla='E';
          ^~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 256 KB Output is correct