結果

問題 No.151 セグメントフィッシング
ユーザー srup٩(๑`н´๑)۶srup٩(๑`н´๑)۶
提出日時 2016-09-08 22:24:21
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 1,397 ms / 5,000 ms
コード長 970 bytes
コンパイル時間 2,745 ms
コンパイル使用メモリ 60,188 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-09 23:58:58
合計ジャッジ時間 16,754 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,384 KB
testcase_01 AC 2 ms
4,384 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,384 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 88 ms
4,384 KB
testcase_09 AC 89 ms
4,384 KB
testcase_10 AC 86 ms
4,384 KB
testcase_11 AC 85 ms
4,384 KB
testcase_12 AC 1,305 ms
4,380 KB
testcase_13 AC 1,284 ms
4,384 KB
testcase_14 AC 1,335 ms
4,380 KB
testcase_15 AC 1,332 ms
4,380 KB
testcase_16 AC 1,326 ms
4,380 KB
testcase_17 AC 1,278 ms
4,380 KB
testcase_18 AC 1,261 ms
4,380 KB
testcase_19 AC 1,397 ms
4,380 KB
testcase_20 AC 1,373 ms
4,380 KB
testcase_21 AC 1,290 ms
4,384 KB
testcase_22 AC 1,255 ms
4,384 KB
testcase_23 AC 29 ms
4,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)

ll al[20010];//左向き
ll ar[20010];//右向き
ll bl[20010];//1ツヅラし
ll br[20010];
int main(void){
	rep(i, 20010) al[i] = ar[i] = 0;

	int n, q; scanf("%d %d", &n, &q);
	rep(i, q){
		char x; int y, z;
		cin >> x >> y >> z;

		if(x == 'L'){
			al[y] += z;
		}else if(x == 'R'){
			ar[y] += z;
		}else if(x == 'C'){
			ll sum = 0;
			for (int p = y; p < z; ++p){
				sum += (al[p] + ar[p]);
			}
			printf("%lld\n", sum);
		}

		//移動
		for (int j = 0; j < n - 1; ++j){
			bl[j] = al[j + 1];
		}
		bl[n - 1] = ar[n - 1];
		for (int j = 0; j < n - 1; ++j){
			br[j + 1] = ar[j];
		}
		br[0] = al[0];

		rep(j, n){
			al[j] = bl[j];
			ar[j] = br[j];
		}
		/*
		rep(j, n){
			printf("%lld ", al[j]);
		}
		printf("\n");
		rep(j, n){
			printf("%lld ", ar[j]);
		}
		printf("\n");
		*/
	}
	return 0;
}
0