Submission #397599

# Submission time Handle Problem Language Result Execution time Memory
397599 2021-05-02T13:53:02 Z victoriad Mobitel (COCI14_mobitel) C++14
50 / 50
1 ms 224 KB
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <utility>
#include <queue>
#include <map>
#include <iomanip>
#include <fstream>
using namespace std;


int main(){
  ios::sync_with_stdio(false);
   cin.tie(NULL);
   vector<int>g(9);
   int a;
   for(int i=0;i<9;i++){
     cin>>a;
     g[a-1]=i+1;
   }
   int ant=-1;
  string s;
  cin>>s;
  for(int i=0;i<s.length();i++){
    if(s[i]=='a'){
      if(ant==g[1]){
        cout<<'#'<<g[1];
      }
      else{
        cout<<g[1];
      }
      ant=g[1];
    }
    else if(s[i]=='b'){
      if(ant==g[1]){
        cout<<'#'<<g[1]<<g[1];
      }
      else{
        cout<<g[1]<<g[1];
      }
      ant=g[1];
    }
    else if(s[i]=='c'){
      if(ant==g[1]){
        cout<<'#'<<g[1]<<g[1]<<g[1];
      }
      else{
        cout<<g[1]<<g[1]<<g[1];
      }
      ant=g[1];
    }
    else if(s[i]=='d'){
      if(ant==g[2]){
        cout<<'#'<<g[2];
      }
      else{
        cout<<g[2];
      }
      ant=g[2];
    }
    else if(s[i]=='e'){
      if(ant==g[2]){
        cout<<'#'<<g[2]<<g[2];
      }
      else{
        cout<<g[2]<<g[2];
      }
      ant=g[2];
    }
    else if(s[i]=='f'){
      if(ant==g[2]){
        cout<<'#'<<g[2]<<g[2]<<g[2];
      }
      else{
        cout<<g[2]<<g[2]<<g[2];
      }
      ant=g[2];
    }
    else if(s[i]=='g'){
      if(ant==g[3]){
        cout<<'#'<<g[3];
      }
      else{
        cout<<g[3];
      }
      ant=g[3];
    }
    else if(s[i]=='h'){
      if(ant==g[3]){
        cout<<'#'<<g[3]<<g[3];
      }
      else{
        cout<<g[3]<<g[3];
      }
      ant=g[3];
    }
    else if(s[i]=='i'){
      if(ant==g[3]){
        cout<<'#'<<g[3]<<g[3]<<g[3];
      }
      else{
        cout<<g[3]<<g[3]<<g[3];
      }
      ant=g[3];
    }
    else if(s[i]=='j'){
      if(ant==g[4]){
        cout<<'#'<<g[4];
      }
      else{
        cout<<g[4];
      }
      ant=g[4];
    }
    else if(s[i]=='k'){
      if(ant==g[4]){
        cout<<'#'<<g[4]<<g[4];
      }
      else{
        cout<<g[4]<<g[4];
      }
      ant=g[4];
    }
    else if(s[i]=='l'){
      if(ant==g[4]){
        cout<<'#'<<g[4]<<g[4]<<g[4];
      }
      else{
        cout<<g[4]<<g[4]<<g[4];
      }
      ant=g[4];
    }
    else if(s[i]=='m'){
      if(ant==g[5]){
        cout<<'#'<<g[5];
      }
      else{
        cout<<g[5];
      }
      ant=g[5];
    }
    else if(s[i]=='n'){
      if(ant==g[5]){
        cout<<'#'<<g[5]<<g[5];
      }
      else{
        cout<<g[5]<<g[5];
      }
      ant=g[5];
    }
    else if(s[i]=='o'){
      if(ant==g[5]){
        cout<<'#'<<g[5]<<g[5]<<g[5];
      }
      else{
        cout<<g[5]<<g[5]<<g[5];
      }
      ant=g[5];
    }
    else if(s[i]=='p'){
      if(ant==g[6]){
        cout<<'#'<<g[6];
      }
      else{
        cout<<g[6];
      }
      ant=g[6];
    }
    else if(s[i]=='q'){
      if(ant==g[6]){
        cout<<'#'<<g[6]<<g[6];
      }
      else{
        cout<<g[6]<<g[6];
      }
      ant=g[6];
    }
    else if(s[i]=='r'){
      if(ant==g[6]){
        cout<<'#'<<g[6]<<g[6]<<g[6];
      }
      else{
        cout<<g[6]<<g[6]<<g[6];
      }
      ant=g[6];
    }
    else if(s[i]=='s'){
      if(ant==g[6]){
        cout<<'#'<<g[6]<<g[6]<<g[6]<<g[6];
      }
      else{
        cout<<g[6]<<g[6]<<g[6]<<g[6];
      }
      ant=g[6];
    }
    else if(s[i]=='t'){
      if(ant==g[7]){
        cout<<'#'<<g[7];
      }
      else{
        cout<<g[7];
      }
      ant=g[7];
    }
    else if(s[i]=='u'){
      if(ant==g[7]){
        cout<<'#'<<g[7]<<g[7];
      }
      else{
        cout<<g[7]<<g[7];
      }
      ant=g[7];
    }
    else if(s[i]=='v'){
      if(ant==g[7]){
        cout<<'#'<<g[7]<<g[7]<<g[7];
      }
      else{
        cout<<g[7]<<g[7]<<g[7];
      }
      ant=g[7];
    }
    else if(s[i]=='w'){
      if(ant==g[8]){
        cout<<'#'<<g[8];
      }
      else{
        cout<<g[8];
      }
      ant=g[8];
    }
    else if(s[i]=='x'){
      if(ant==g[8]){
        cout<<'#'<<g[8]<<g[8];
      }
      else{
        cout<<g[8]<<g[8];
      }
      ant=g[8];
    }
    else if(s[i]=='y'){
      if(ant==g[8]){
        cout<<'#'<<g[8]<<g[8]<<g[8];
      }
      else{
        cout<<g[8]<<g[8]<<g[8];
      }
      ant=g[8];
    }
    else if(s[i]=='z'){
      if(ant==g[8]){
        cout<<'#'<<g[8]<<g[8]<<g[8]<<g[8];
      }
      else{
        cout<<g[8]<<g[8]<<g[8]<<g[8];
      }
      ant=g[8];
    }
    

  }
  return 0;
}

Compilation message

mobitel.cpp: In function 'int main()':
mobitel.cpp:26:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |   for(int i=0;i<s.length();i++){
      |               ~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 224 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct