Submission #960256

# Submission time Handle Problem Language Result Execution time Memory
960256 2024-04-10T03:50:47 Z khangrl Mobitel (COCI14_mobitel) C++14
50 / 50
1 ms 348 KB
#include<bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define pb push_back
using namespace std;
int main(){
	int arr[10];
	for(int i=1; i<=9; i++){
		int a;
		cin>>a;
		arr[a]=i;
	}
	string s;
	cin>>s;
	int last=0;
	for(int i=0; i<s.size(); i++){
		int n, k=s[i];
		if(s[i]=='a' or s[i]=='b' or s[i]=='c'){
			if(arr[2]==last){
				cout<<'#';
			}
			last=arr[2];
			n='a';
			n--;
		}
		else if(s[i]=='d' or s[i]=='e' or s[i]=='f'){
			if(arr[3]==last){
				cout<<'#';
			}			
		    last=arr[3];
			n='d';
			n--;
	    }
		else if(s[i]=='g' or s[i]=='h' or s[i]=='i'){
			if(arr[4]==last){
				cout<<'#';
			}
			last=arr[4];
			n='g';
			n--;
	    }
		else if(s[i]=='j' or s[i]=='k' or s[i]=='l'){
			if(arr[5]==last){
				cout<<'#';
			}
			last=arr[5];
			n='j';
			n--;
		}
		else if(s[i]=='m' or s[i]=='n' or s[i]=='o'){
			if(arr[6]==last){
				cout<<'#';
			}
			last=arr[6];
			n='m';
			n--;
		}
		else if(s[i]=='p' or s[i]=='q' or s[i]=='r' or s[i]=='s'){
			if(arr[7]==last){
				cout<<'#';
			}
			last=arr[7];
			n='p';
			n--;
		}
		else if(s[i]=='t' or s[i]=='u' or s[i]=='v'){
			if(arr[8]==last){
				cout<<'#';
			}
			last=arr[8];
			n='t';
			n--;
		}
		else if(s[i]=='w' or s[i]=='x' or s[i]=='y' or s[i]=='z'){
			if(arr[9]==last){
				cout<<'#';
			}
			last=arr[9];
			n='w';
			n--;
		}
		k-=n;
		while(k--){
			cout<<last;
		}
	}
}

Compilation message

mobitel.cpp: In function 'int main()':
mobitel.cpp:17:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |  for(int i=0; i<s.size(); i++){
      |               ~^~~~~~~~~
mobitel.cpp:83:4: warning: 'n' may be used uninitialized in this function [-Wmaybe-uninitialized]
   83 |   k-=n;
      |   ~^~~
# Verdict Execution time Memory 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 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct