結果

問題 No.2482 Sandglasses
ユーザー SnowBeenDidingSnowBeenDiding
提出日時 2023-09-29 19:08:40
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 359 ms / 2,000 ms
コード長 982 bytes
コンパイル時間 5,500 ms
コンパイル使用メモリ 320,168 KB
実行使用メモリ 20,736 KB
最終ジャッジ日時 2024-11-16 22:58:37
合計ジャッジ時間 17,466 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#include <atcoder/all>
#define rep(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
using namespace std;
using namespace atcoder;

typedef long long ll;

ll f(ll n, ll x, ll t, char c) {
    t %= n * 2;
    if (t >= n) {
        c ^= 'A';
        c ^= 'B';
        x = n - x;
        t -= n;
    }
    if (c == 'B') {
        if (x + t <= n) {
            return x + t;
        } else {
            ll mi = x + t - n;
            return n - mi;
        }
    } else {
        return abs(x - t);
    }
}

int main() {
    ll n, k, t;
    cin >> n >> k >> t;
    vector<char> a(n);
    vector<ll> b(n);
    rep(i, 0, n) cin >> a[i];
    rep(i, 0, n) cin >> b[i];
    vector<ll> bsort = b;
    sort(bsort.begin(), bsort.end());
    vector<ll> anssort(n);
    rep(i, 0, n) { anssort[i] = f(k, b[i], t, a[i]); }
    sort(anssort.begin(), anssort.end());
    map<ll, ll> mp;
    rep(i, 0, n) mp[bsort[i]] = anssort[i];
    rep(i, 0, n) cout << mp[b[i]] << ' ';
}
0