제출 #1341805

#제출 시각아이디문제언어결과실행 시간메모리
1341805doantaolaaidiTavan (COCI16_tavan)C++20
48 / 80
1 ms344 KiB
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define AC "test"
#define foru(i, l, r) for (int i = (l); i <= (r); i++)
#define ford(i, l, r) for (int i = (l); i >= (r); i--)
#define fi first
#define se second

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vii;
typedef vector<ll> vll;

const ll inf = 1e9 + 7;
const ll linf = 1e18 + 7;
const int mod = 1e9 + 7;
const int maxn = 5e2 + 7;
const int base = 31;

void fastIO(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
}

ll mul(ll a, ll b){
    a%=mod;
    ll res = 0;
    while (b){
        if (b%2) res = (res + a)%mod;
        a = (a + a)%mod;
        b/=2;
    }
    return res;
}

ll Pow(ll a, ll b){
    ll ans = 1;
    while (b){
        if (b % 2) ans = mul(ans, a);
        a = mul(a, a);
        b/=2;
    }
    return ans;
}

string s, t[maxn];
ll n, m, k, x, tmp, res[maxn], val;

void inp(){
    cin >> n >> m >> k >> x;
    cin >> s;
    memset(res, 1, sizeof(res));
    foru(i, 1, m){
        cin >> t[i];
        sort(t[i].begin(), t[i].end());
    }
    tmp = 0;
    val = k;
    foru(i, 1, m){
        if (val < x){
            val = val * k;
            tmp++;
        }
    }
    val/=k;
    foru(i, 1, tmp + 1){
        res[i] = ceil((double)x/val);
        x = x%val;
        val/=k;
        if (x == 0){
            foru(j, i + 1, m){
                res[j] = k;
            }
            break;
        }
    }
    int cnt = 1;
    for (char c: s){
        if (c == '#'){
            cout << (t[cnt][res[cnt] - 1]);
            cnt++;
        }
        else cout << c;
    }
}

int main(){
    fastIO();
    if (fopen(AC".inp", "r")){
        freopen(AC".inp", "r", stdin);
        freopen(AC".out", "w", stdout);
    }
    inp();
}

컴파일 시 표준 에러 (stderr) 메시지

tavan.cpp: In function 'int main()':
tavan.cpp:92:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   92 |         freopen(AC".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
tavan.cpp:93:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   93 |         freopen(AC".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...