結果

問題 No.2482 Sandglasses
ユーザー matsup10matsup10
提出日時 2023-09-22 22:15:46
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 169 ms / 2,000 ms
コード長 1,176 bytes
コンパイル時間 5,430 ms
コンパイル使用メモリ 323,504 KB
実行使用メモリ 7,296 KB
最終ジャッジ日時 2024-04-28 09:02:17
合計ジャッジ時間 12,121 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 165 ms
7,296 KB
testcase_04 AC 155 ms
7,168 KB
testcase_05 AC 148 ms
7,168 KB
testcase_06 AC 144 ms
7,296 KB
testcase_07 AC 145 ms
7,296 KB
testcase_08 AC 141 ms
7,168 KB
testcase_09 AC 142 ms
7,296 KB
testcase_10 AC 140 ms
7,296 KB
testcase_11 AC 139 ms
7,296 KB
testcase_12 AC 140 ms
7,296 KB
testcase_13 AC 144 ms
7,168 KB
testcase_14 AC 142 ms
7,168 KB
testcase_15 AC 141 ms
7,168 KB
testcase_16 AC 141 ms
7,296 KB
testcase_17 AC 141 ms
7,296 KB
testcase_18 AC 169 ms
7,168 KB
testcase_19 AC 142 ms
7,296 KB
testcase_20 AC 145 ms
7,168 KB
testcase_21 AC 143 ms
7,296 KB
testcase_22 AC 154 ms
7,168 KB
testcase_23 AC 138 ms
7,168 KB
testcase_24 AC 142 ms
7,296 KB
testcase_25 AC 136 ms
7,296 KB
testcase_26 AC 140 ms
7,296 KB
testcase_27 AC 138 ms
7,296 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/extc++.h>
#include <atcoder/all>

using namespace std;
using ll = long long;
#define REP(i,n) for(int i=0;i<int(n);i++)
#define FOR(i,a,b) for(int i=a;i<=int(b);i++)
#define ALL(x) x.begin(),x.end()
#define INF INT_MAX
#define INFL LLONG_MAX / 4
using namespace atcoder;
using mint = modint998244353;
template<typename T> void chmin(T& a, T b) { a = min(a, b); }
template<typename T> void chmax(T& a, T b) { a = max(a, b); }
#define PR(x) cerr << #x << "=" << x << endl
using i128 = __int128_t;

int main() {
  ll n, k, t;
  cin >> n >> k >> t;
  vector<int> ab(n);
  vector<ll> b(n);
  REP(i, n) {
    char c;
    cin >> c;
    ab[i] = c - 'A';
  }
  REP(i, n) cin >> b[i];

  vector<int> ord(n);
  iota(ALL(ord), 0);
  sort(ALL(ord), [&](int i, int j){
    return b[i] < b[j];
  });
  REP(i, n) {
    if(ab[i] == 1) {
      ll nb = (b[i] + t) % (2*k);
      if(nb > k) nb = 2*k-nb;
      b[i] = nb;
    } else {
      ll nb = (k - b[i] + t) % (2*k);
      if(nb > k) nb -= k;
      else nb = k - nb;
      b[i] = nb;
    }
  }

  sort(ALL(b));

  vector<int> ans(n);
  REP(i, n) {
    ans[ord[i]] = b[i];
  }

  REP(i, n) cout << ans[i] << ' ';

  return 0;
}
0