标签:模拟 sizeof while nbsp test else tac pac cos
https://acm.ecnu.edu.cn/contest/231/problem/A/
题意:给你长度为n的单词,其中有m个是#表示不确定字母,每个#有k个候选字母,将所有可以单词按字典序排序,问第x个单词是?
解法:模拟进制顺序。
//#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <string>
#include <stdio.h>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string.h>
#include<time.h>
#include <vector>
#define ME(x , y) memset(x , y , sizeof(x))
#define SF(n) scanf("%d" , &n)
#define rep(i , n) for(int i = 0 ; i < n ; i ++)
#define INF 0x3f3f63f3f
#define mod 20191117
#define PI acos(-1)
using namespace std;
typedef long long ll ;
ll n , m , k , x ;
char s[500009];
int a[500009];
char str[500009];
char b[500009];
void turn(ll x)
{
int l = 0 ;
while(x)
{
a[l++] = x % k ;
x /= k ;
}
}
int main()
{
/*#ifdef ONLINE_JUDGE
#else
freopen("D:/c++/in.txt", "r", stdin);
freopen("D:/c++/out.txt", "w", stdout);
#endif*/
int flag = 0 ;
scanf("%lld%lld%lld%lld" , &n , &m , &k ,&x);
scanf("%s" , s);
int len = strlen(s);
x -- ;//使顺序与进制数组对应起来
turn(x);
int l = 0 ;
for(int i = 0 ; i < m / 2; i++)//调整进制顺序
{
int t ;
t = a[m - i - 1];
a[m-i-1] = a[i];
a[i] = t ;
}
for(int i = 0 ; i < m ; i++)
{
scanf("%s" , str);
sort(str , str+k);
b[l++] = str[a[i]];
}
l = 0 ;
for(int i = 0 ; i < n ; i++)
{
if(s[i] == ‘#‘)
{
s[i] = b[l++];
}
}
printf("%s\n" , s);
return 0;
}
标签:模拟 sizeof while nbsp test else tac pac cos
原文地址:https://www.cnblogs.com/nonames/p/11961075.html