답안 #156423

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
156423 2019-10-05T15:07:02 Z mdn2002 Tavan (COCI16_tavan) C++14
80 / 80
2 ms 376 KB
#include<bits/stdc++.h>
using namespace std;
long long mod=1e9+7;
int n,m,k,x;
string s;
vector<string>v;
vector<char>c;
long long pw(int xz,int y)
{
    long long xx=1;
    for(int i=0;i<y;i++)
    {
        xx*=xz;
        if(xx>x)return x+4;
    }
    return xx;
}

int main()
{
    cin>>n>>m>>k>>x;
    cin>>s;
    for(int i=0;i<m;i++)
    {
        string x;
        cin>>x;
        sort(x.begin(),x.end());
        v.push_back(x);
    }
    for(int i=0;i<m;i++)
    {
        long long mx=0,lmx=0;
        for(int j=0;j<k;j++)
        {
            mx+=pw(k,m-i-1);
            if(mx>=x)
            {
                c.push_back(v[i][j]);
                x-=lmx;
                break;
            }
            lmx=mx;
        }
    }
    int kk=0;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]=='#')cout<<c[kk++];
        else cout<<s[i];
    }
}

Compilation message

tavan.cpp: In function 'int main()':
tavan.cpp:46:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0;i<s.size();i++)
                 ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 256 KB Output is correct