結果

問題 No.1021 Children in Classrooms
ユーザー momoharamomohara
提出日時 2020-04-10 21:55:34
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 34 ms / 2,000 ms
コード長 2,235 bytes
コンパイル時間 1,562 ms
コンパイル使用メモリ 170,740 KB
実行使用メモリ 5,300 KB
最終ジャッジ日時 2023-10-14 00:26:53
合計ジャッジ時間 3,462 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,352 KB
testcase_01 AC 1 ms
4,352 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 1 ms
4,352 KB
testcase_04 AC 2 ms
4,352 KB
testcase_05 AC 2 ms
4,352 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,352 KB
testcase_08 AC 2 ms
4,352 KB
testcase_09 AC 34 ms
5,216 KB
testcase_10 AC 33 ms
5,224 KB
testcase_11 AC 32 ms
5,064 KB
testcase_12 AC 33 ms
5,004 KB
testcase_13 AC 34 ms
5,056 KB
testcase_14 AC 33 ms
5,000 KB
testcase_15 AC 25 ms
4,656 KB
testcase_16 AC 25 ms
4,688 KB
testcase_17 AC 26 ms
4,688 KB
testcase_18 AC 33 ms
5,300 KB
testcase_19 AC 4 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>

using namespace std;

#define rep(i,m,n) for(int (i)=(int)(m);(i)<(int)(n);(i)++)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;(i)>=(int)(m);(i)--)
#define REP(i,n) rep(i,0,n)
#define REP2(i,n) rep2(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;

typedef vector<ll> Array;
typedef vector<Array> Matrix;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

//constexpr long long MOD = (ll) 1e9+7;
constexpr long long MOD = 998244353;

template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

struct Edge {
	int to, cap, rev;
	Edge(int _to, int _cap, int _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, int from, int to, int cap, bool revFlag, int revCap) {
	G[from].push_back(Edge(to, cap, G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, G[from].size() - 1));
}

void solve() {
    ll n,m;
    cin>>n>>m;
    Array a(n);
    REP(i,n) cin>>a[i];
    string s;
    cin>>s;

    ll pos=0;
    REP(i,m){
        if(s[i]=='R'){ 
            pos--;
            if(pos+n-1<0){
                pos = -n+1;
                continue;
            }
            if(pos+n<n && pos+n-1>=0){
                a[pos+n-1]+=a[pos+n];
                a[pos+n]=0; 
            }
        }else{ 
            pos++;
            if(pos==n){
                pos=n-1;
                continue;
            }
            if(pos > 0 && pos-1 >= 0){
                a[pos]+=a[pos-1];
                a[pos-1]=0; 
            }
        }
    }

    REP(i,n){
        if(pos>=0 && pos<n) cout<<a[pos]<<" ";
        else cout<<0<<" ";
        pos++;
    }
    cout<<en;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	solve();
	//int t; cin >> t; REP(i, t) solve();

	return 0;
}
0