# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
94136 | 2019-01-16T11:31:47 Z | hamzqq9 | Tavan (COCI16_tavan) | C++14 | 2 ms | 504 KB |
#include<bits/stdc++.h> #define st first #define nd second #define pb push_back #define ppb pop_back #define ppf pop_front #define umax(x,y) x=max(x,y) #define umin(x,y) x=min(x,y) #define ll long long #define ii pair<int,int> #define iii pair<ii,int> #define iiii pair<ii,ii> #define sz(x) ((int) x.size()) #define orta ((bas+son)/2) #define all(x) x.begin(),x.end() #define dbgs(x) cerr<<(#x)<<" --> "<<(x)<<" " #define dbg(x) cerr<<(#x)<<" --> "<<(x)<<endl;getchar() #define pw(x) (1<<(x)) #define inf 1000000000000000000ll #define MOD 1000000007 #define N 505 #define M 15000005 #define LOG 20 #define KOK 650 #define EPS 0.00001 using namespace std; int n,m,k,x; int len[N],suf[N]; char mn[N],let[N]; char s[N][29]; int mul(int x,int y) { if(1ll*x*y>=1000000000) return 1000000001; return x*y; } int main() { //freopen("input.txt","r",stdin); scanf("%d %d %d %d",&n,&m,&k,&x); scanf("%s",mn+1); for(int i=1;i<=m;i++) { scanf("%s",s[i]+1); len[i]=strlen(s[i]+1); sort(s[i]+1,s[i]+1+len[i]); } suf[m+1]=1; for(int i=m;i>=1;i--) { suf[i]=mul(suf[i+1],len[i]); } for(int i=1;i<=m;i++) { for(int j=1;j<=len[i];j++) { if(suf[i+1]<x) { x-=suf[i+1]; } else { let[i]=s[i][j]; break ; } } } int ptr=1; for(int i=1;i<=n;i++) { if(mn[i]=='#') { mn[i]=let[ptr++]; } printf("%c",mn[i]); } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 504 KB | Output is correct |
2 | Correct | 2 ms | 256 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 256 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 256 KB | Output is correct |
8 | Correct | 2 ms | 376 KB | Output is correct |
9 | Correct | 2 ms | 256 KB | Output is correct |
10 | Correct | 2 ms | 256 KB | Output is correct |