結果

問題 No.151 セグメントフィッシング
ユーザー diginatudiginatu
提出日時 2015-02-13 00:39:54
言語 D
(dmd 2.107.1)
結果
AC  
実行時間 777 ms / 5,000 ms
コード長 765 bytes
コンパイル時間 605 ms
コンパイル使用メモリ 92,224 KB
実行使用メモリ 4,372 KB
最終ジャッジ日時 2023-09-02 19:49:27
合計ジャッジ時間 4,940 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,372 KB
testcase_01 AC 1 ms
4,372 KB
testcase_02 AC 1 ms
4,368 KB
testcase_03 AC 1 ms
4,372 KB
testcase_04 AC 1 ms
4,368 KB
testcase_05 AC 2 ms
4,372 KB
testcase_06 AC 1 ms
4,368 KB
testcase_07 AC 2 ms
4,368 KB
testcase_08 AC 22 ms
4,372 KB
testcase_09 AC 22 ms
4,372 KB
testcase_10 AC 23 ms
4,372 KB
testcase_11 AC 22 ms
4,368 KB
testcase_12 AC 288 ms
4,368 KB
testcase_13 AC 292 ms
4,368 KB
testcase_14 AC 289 ms
4,372 KB
testcase_15 AC 289 ms
4,372 KB
testcase_16 AC 284 ms
4,372 KB
testcase_17 AC 15 ms
4,368 KB
testcase_18 AC 15 ms
4,368 KB
testcase_19 AC 777 ms
4,368 KB
testcase_20 AC 768 ms
4,372 KB
testcase_21 AC 44 ms
4,372 KB
testcase_22 AC 41 ms
4,368 KB
testcase_23 AC 18 ms
4,372 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.stdio, std.conv, std.math, std.string, std.range, std.array,
       std.algorithm;

void main(){
  auto buf = readln().strip().split().map!(to!int)().array;
  immutable N = buf[0];
  immutable Q = buf[1];

  immutable M = 2*N;
  auto map = new long[](M);
  
  foreach(immutable int t; 1 .. Q+1) {
    auto p = readln().strip().split();
    immutable x = p[0].to!string();
    immutable y = p[1].to!int();
    immutable z = p[2].to!int();
    if(x == "R") {
      map[(M-1-y+t) % M] += z;
    }else if(x == "L") {
      map[(y+t) % M] += z;
    }else if(x == "C") {
      long sum;
      foreach(immutable i; y+t .. z+t)
        sum += map[i%M];
      foreach(immutable i; M-1-z+t+1 .. M-1-y+t+1)
        sum += map[i%M];
      writeln(sum);
    }
  }

}
0