답안 #105873

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
105873 2019-04-15T12:02:08 Z leonarda Tavan (COCI16_tavan) C++14
80 / 80
3 ms 512 KB
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair<int, int> pi;
typedef long long int lint;
const int inf = 0x3f3f3f3f;
const int maxn = 500 + 5;

int n, m, k, x;
string s;
string v[maxn];

string switchBase(int num, int base) {
	string t;
	while(num) {
		t += (num % base) + '0';
		num /= base;
	}
	return t;
}

int main ()
{
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	
	cin >> n >> m >> k >> x;
	cin >> s;
	for(int i = 0; i < m; ++i) {
		cin >> v[i];
		sort(v[i].begin(), v[i].end());
	}
	
	string rj = switchBase(x - 1, k);
	while(rj.size() != m) 
		rj.pb('0');

	reverse(rj.begin(), rj.end());
	
	int indeks = 0;
	for(auto x : rj)
		s[s.find('#')] = v[indeks++][x - '0'];
	
	cout << s;

return 0;
}

Compilation message

tavan.cpp: In function 'int main()':
tavan.cpp:38:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  while(rj.size() != m) 
        ~~~~~~~~~~^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 512 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 404 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 3 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 3 ms 384 KB Output is correct