Submission #740306

# Submission time Handle Problem Language Result Execution time Memory
740306 2023-05-12T09:42:35 Z mzv Tavan (COCI16_tavan) C++17
80 / 80
1 ms 340 KB
#include <bits/stdc++.h>

#define ccd ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define endl '\n'

using namespace std;

/* ------------------------ hi lol ------------------------ */

ll n,m,k,x,cur=1,xm=1,z=0;
string words[501],s;
vector<int>idx;

int main() {
	ccd
	cin >> n >> m >> k >> x;
	cin >> s;
	for (int i=1;i<=m;i++) {
		cin >> words[i];
		sort(words[i].begin(),words[i].end());
	}
	while (xm*k<x) {
		xm*=k;
		cur++;
	}
	while (idx.size()<m-cur) {
		idx.push_back(1);
	}
//	cout << cur << endl;
	while (cur>=1) {
		if (x%xm!=0) {
			idx.push_back((x/xm)+1);
		}
		else {
			idx.push_back((x/xm));
		}
		while (x>xm) {
			x-=xm;
		}
		xm/=k;
		cur--;
	}
//	for (auto i : idx) {
//		cout << i << " ";
//	} cout << endl;
	cur=1;
	for (int i=0;i<n;i++) {
		if (s[i]=='#') {
			cout << words[cur][(idx.at(z)-1)];
			z++;
			cur++;
		}
		else {
			cout << s[i];
		}
	}
}

// pake modular nyari alphabetical order

Compilation message

tavan.cpp: In function 'int main()':
tavan.cpp:27:19: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   27 |  while (idx.size()<m-cur) {
      |         ~~~~~~~~~~^~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct