結果

問題 No.1021 Children in Classrooms
ユーザー NeccoliniNeccolini
提出日時 2020-10-01 00:53:28
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 77 ms / 2,000 ms
コード長 2,454 bytes
コンパイル時間 1,580 ms
コンパイル使用メモリ 171,524 KB
実行使用メモリ 5,184 KB
最終ジャッジ日時 2023-09-20 21:12:00
合計ジャッジ時間 5,510 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 3 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 72 ms
5,068 KB
testcase_10 AC 73 ms
5,148 KB
testcase_11 AC 72 ms
5,184 KB
testcase_12 AC 72 ms
5,128 KB
testcase_13 AC 72 ms
5,104 KB
testcase_14 AC 71 ms
5,072 KB
testcase_15 AC 54 ms
4,908 KB
testcase_16 AC 54 ms
4,740 KB
testcase_17 AC 57 ms
4,852 KB
testcase_18 AC 77 ms
5,072 KB
testcase_19 AC 7 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long LL;
typedef long double ld;
typedef vector<ll>VI;
typedef pair<int,int>P;
#define VV(T) vector<vector<T>>
#define sz(x) int(x.size())
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define reprev(i,n) for (ll i=(ll)n-1;i>=0;i--)
#define ALL(a)  (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define c_max(a, b) (((ll)a)>((ll)b)?(a):(b))
#define c_min(a,b) (((ll)a)<((ll)b)?(a):(b))
#define chmax(x,a) x=c_max(x,a)
#define chmin(x,a) x=c_min(x,a)
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define $(x) {cout<<#x<<" = " <<(x)<<endl;}
#define fi first
#define se second
#define MAX 100100//5
#define MAX2 200100
#define MAX6 1001001//6
#define MAX7 10010010//7
#define SENTINEL 2000000000//9
#define INF 1<<30
#define INFTY 1LL<<61
#define MAX_INT INT_MAX
#define Endl '\n'
#define CLR(mat) memset(mat, 0, sizeof(mat))
inline ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}//最大公約数
inline ll lcm(ll a,ll b){return a*b/GCD(a,b);}//最小公倍数
template<class T> bool contain(const std::string& s, const T& v) {
   return s.find(v) != std::string::npos;
}
const int MOD = 1000000007;
inline ll mod_add(ll a,ll b){return (a+b)%MOD;}
inline ll mod_sub(ll a,ll b){return (a+MOD-b)%MOD;}
inline ll mod_mul(ll a,ll b){return ((a%MOD)*(b%MOD))%MOD;}
inline ll mod_pow(ll x,ll n,ll mod=(ll)MOD){ll res=1;while(n>0){
if(n&1)res=res*x%mod;
x=x*x%mod;n>>=1;}return res;}
inline ll mod_inv(ll x){return mod_pow(x,MOD-2);}
inline ll mod_div(ll a, ll b){return mod_mul(a,mod_inv(b));}
//const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
// vector型から重複を削除 list.erase(unique(ALL(list)),list.end());
// g++ -o a a.cpp -Wall -lm -std=c++17
//push_back -> emplace_back
ll n,m,a;
string S;


int main(){
   cin>>n>>m;
   deque<ll>d;
   rep(i,n){
      cin>>a;
      d.push_back(a);
   };
   cin>>S;
   rep(i,m){
      if(S[i]=='L'){
         ll x=d.front();
         d.pop_front();
         ll y=d.front();
         d.pop_front();
         d.push_front(x+y);
         d.push_back(0);
      }
      else{
         ll x=d.back();
         d.pop_back();
         ll y=d.back();
         d.pop_back();
         d.push_back(x+y);
         d.push_front(0);
      }
   }
   while(d.size()){
      ll ans=d.front();
      d.pop_front();
      cout<<ans<<" ";
   }
   cout<<endl;
}
0