Submission #165964

# Submission time Handle Problem Language Result Execution time Memory
165964 2019-11-29T21:33:46 Z sans Tavan (COCI16_tavan) C++14
64 / 80
2 ms 376 KB
#include <iostream>
#include <numeric>
#include <cmath>
#include <algorithm>
#include <vector>

using namespace std;

#define sp ' '
#define st first
#define nd second
#define pb push_back
#define mp make_pair
#define forn(YY, yy) for(long long int yy = 0; yy < YY; ++yy)
#define prn(XX) cout << XX << endl
#define prs(XX) cout << XX << " "

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;

const int MOD = 1e9 + 7;
const int INF = 2e9 + 13;
const int mINF = -2e9 - 13;
const double PI = 3.14159265358979;
const double EPS = 1e-9;

const long long MAX_X = 1e9 + 13;

int N, M, K, X;

vector<vector<char>> L;
vector<char> Secimler;
vll Usler;

int main(int argc, char **argv){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

    cin >> N >> M >> K >> X;
    string Word; cin >> Word;
    Secimler.resize(M);

    Usler.pb(1);
    for(int i = 1; Usler[i-1]*K <= MAX_X*K; ++i) Usler.pb(Usler[i-1]*K);

    L.resize(M, vector<char>(K));

    for(int i = 0; i < M; ++i){
        for(int j = 0; j < K; ++j) cin >> L[i][j];
        sort(L[i].begin(), L[i].end());
    }

    ll S = 0;
    for(int i = 1; i <= M; ++i){
        for(int j = 1; j <= K; ++j){
            if( S + (j-1)*Usler[M-i] + 1 <= X and S + j*Usler[M-i] >= X){
                //printf("%lld - %lld\n", S + (j-1)*Usler[M-i] + 1, S + j*Usler[M-i]);
                Secimler[i-1] = L[i-1][j-1];
                S += (j-1)*Usler[M-i];
                break;
            }
        }
    }

    int j = 0;
    for(int i = 0; i < N; ++i) cout << (Word[i] == '#' ? (Secimler[j++] == 0 ? L[j-1][0] : Secimler[j-1]) : Word[i]);
    cout << endl;

    return 0;
}

//cikisir

# Verdict Execution time Memory 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 256 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Incorrect 2 ms 376 KB Output isn't correct
8 Correct 2 ms 376 KB Output is correct
9 Incorrect 2 ms 376 KB Output isn't correct
10 Correct 2 ms 376 KB Output is correct