Submission #328810

# Submission time Handle Problem Language Result Execution time Memory
328810 2020-11-18T06:40:56 Z Halit Mobitel (COCI14_mobitel) C++17
50 / 50
1 ms 384 KB
#include <bits/stdc++.h>
using namespace std;

int main(){
	vector<int> v(9);
	for(int &e : v)
		cin >> e;

	vector<int> pre = { 0, 3, 6, 9, 12, 15, 19, 22, 26};
	int last = 1;

	string s;
	cin >> s;

	auto to_int = [&](char ch){ return ch-'a'+1; };

	auto write = [&](int cur){
		
		int digit = 2, F;
		for(int i = 0;i+1 < 9;++i)
			if(cur > pre[i] && cur <= pre[i+1])
				digit += i, F = cur-pre[i];

		if(last == digit)
			cout << '#';

		for(int j = 0;j < 9;++j)
			if(v[j] == digit)
				for(int i = 0;i < F;++i)
					cout << j+1;

		last = digit;
	};

	for(char e : s)
		write(to_int(e));
}

Compilation message

mobitel.cpp: In function 'int main()':
mobitel.cpp:29:21: warning: 'F' may be used uninitialized in this function [-Wmaybe-uninitialized]
   29 |     for(int i = 0;i < F;++i)
      |                   ~~^~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct