답안 #95560

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
95560 2019-02-02T05:26:46 Z oolimry Tavan (COCI16_tavan) C++14
80 / 80
2 ms 380 KB
#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n, m, k, x;
    //freopen("i.txt","r",stdin);
    scanf("%d %d %d %d",&n,&m,&k,&x);
    string s;
    cin >> s;

    string arr[m];
    for(int i = 0;i < m;i++){
        cin >> arr[i];
    }

    reverse(arr, arr + m);
    char carr[m][k];
    for(int i=  0;i < m;i++){
        for(int j = 0;j < k;j++){
            carr[i][j] = arr[i].at(j);
        }
    }

    for(int i =0;i < m;i++){
        sort(carr[i], carr[i] + k);
    }

    int index = 0;
    x--;
    for(int i = n - 1;i >= 0 ;i--){
        char c = s.at(i);
        if(c != '#'){
            continue;
        }
        s[i] = carr[index][x % k];
        x /= k;
        index++;
    }
    for(int i=  0;i < m;i++){
        for(int j = 0;j < k;j++){
            //printf("%c ",carr[i][j]);
        }
       // printf("\n");
    }

    cout << s;
    return 0;
}

Compilation message

tavan.cpp: In function 'int main()':
tavan.cpp:9:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d %d %d",&n,&m,&k,&x);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 380 KB Output is correct
5 Correct 2 ms 376 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 376 KB Output is correct
10 Correct 2 ms 252 KB Output is correct