結果
| 問題 |
No.151 セグメントフィッシング
|
| コンテスト | |
| ユーザー |
srup٩(๑`н´๑)۶
|
| 提出日時 | 2016-09-08 22:24:21 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 746 ms / 5,000 ms |
| コード長 | 970 bytes |
| コンパイル時間 | 707 ms |
| コンパイル使用メモリ | 59,360 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-15 22:25:47 |
| 合計ジャッジ時間 | 9,045 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 5 |
| other | AC * 19 |
コンパイルメッセージ
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);
| ~~~~~^~~~~~~~~~~~~~~~~
ソースコード
#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;
}
srup٩(๑`н´๑)۶