結果

問題 No.151 セグメントフィッシング
ユーザー srup٩(๑`н´๑)۶srup٩(๑`н´๑)۶
提出日時 2016-09-08 22:24:21
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 662 ms / 5,000 ms
コード長 970 bytes
コンパイル時間 523 ms
コンパイル使用メモリ 60,408 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-27 18:04:54
合計ジャッジ時間 8,191 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,816 KB
testcase_01 AC 1 ms
6,940 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 2 ms
6,944 KB
testcase_08 AC 41 ms
6,944 KB
testcase_09 AC 39 ms
6,944 KB
testcase_10 AC 45 ms
6,944 KB
testcase_11 AC 45 ms
6,940 KB
testcase_12 AC 604 ms
6,944 KB
testcase_13 AC 579 ms
6,940 KB
testcase_14 AC 603 ms
6,940 KB
testcase_15 AC 575 ms
6,944 KB
testcase_16 AC 579 ms
6,944 KB
testcase_17 AC 554 ms
6,940 KB
testcase_18 AC 546 ms
6,940 KB
testcase_19 AC 647 ms
6,944 KB
testcase_20 AC 662 ms
6,940 KB
testcase_21 AC 568 ms
6,944 KB
testcase_22 AC 572 ms
6,940 KB
testcase_23 AC 24 ms
6,944 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:16:24: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   16 |         int n, q; scanf("%d %d", &n, &q);
      |                   ~~~~~^~~~~~~~~~~~~~~~~

ソースコード

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