답안 #208892

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
208892 2020-03-12T12:07:51 Z DysonSphere Tavan (COCI16_tavan) C++14
48 / 80
5 ms 380 KB
#include<bits/stdc++.h>
using namespace std;
int main(){
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	int n,m,k,x;
	cin>>n>>m>>k>>x;
	x--;
	string smain;
	cin>>smain;
	string arr[m];
	for(int i=0;i<m;i++){
		cin>>arr[i];
		sort(arr[i].begin(), arr[i].end());
	}
	int inds[m];
	for(int i=0;i<m;i++){
		inds[i]=-1;
	}
	long long int mults[m];
	mults[m-1]=1;
	for(int i=m-2;i>=0;i--){
		mults[i]=mults[i+1]*k;
		if(mults[i]>x){
			for(int j=0;j<=i;j++){
				inds[j]=0;
			}
			break;
		}
	}
	for(int i=0;i<m;i++){
		if(inds[i]==-1){
			int mul=0,ind=-1;
			while(x>=mul){
				ind++;
				mul+=mults[i];
			}
			mul-=mults[i];
			inds[i]=ind;
			x-=mul;
		}
	}
	for(int i=0,ind=0;i<n;i++){
		if(smain[i]!='#'){
			cout<<smain[i];
		}
		else{
			cout<<arr[ind][inds[ind]];
		}
	}
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 5 ms 380 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 256 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Incorrect 5 ms 256 KB Output isn't correct
8 Incorrect 5 ms 376 KB Output isn't correct
9 Incorrect 5 ms 376 KB Output isn't correct
10 Incorrect 5 ms 256 KB Output isn't correct