結果
問題 | No.151 セグメントフィッシング |
ユーザー |
![]() |
提出日時 | 2015-02-13 00:39:54 |
言語 | D (dmd 2.109.1) |
結果 |
AC
|
実行時間 | 783 ms / 5,000 ms |
コード長 | 765 bytes |
コンパイル時間 | 885 ms |
コンパイル使用メモリ | 103,552 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-12 02:11:54 |
合計ジャッジ時間 | 4,916 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 19 |
ソースコード
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);}}}