結果

問題 No.259 セグメントフィッシング+
ユーザー shimomireshimomire
提出日時 2015-02-16 18:05:11
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,648 bytes
コンパイル時間 845 ms
コンパイル使用メモリ 111,568 KB
実行使用メモリ 115,948 KB
最終ジャッジ日時 2023-09-06 01:37:41
合計ジャッジ時間 4,931 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
8,756 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 TLE -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cassert>// c
#include <iostream>// io
#include <iomanip>
#include <fstream>
#include <sstream>
#include <vector>// container
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <algorithm>// other
#include <complex>
#include <numeric>
#include <functional>
#include <random>
#include <regex>
using namespace std;

using ll =long long;

#define ALL(c) (begin(c)),(end(c))
#define REP(i,n) FOR(i,0,n)
#define REPr(i,n) FORr(i,0,n)
#define FOR(i,l,r) for(int i=(int)(l);i<(int)(r);++i)
#define FORr(i,l,r) for(int i=(int)(r)-1;i>=(int)(l);--i)
#define EACH(it,o) for(auto it = (o).begin(); it != (o).end(); ++it)
#define IN(l,v,r) ((l)<=(v) && (v)<(r))
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end())
//debug
#define DUMP(x)  cerr << #x << " = " << (x)
#define LINE()    cerr<< " (L" << __LINE__ << ")"

ll pmod(ll v,ll M){return (v%M+M)%M;}

// O(Q^2)
int main(){
	cout <<fixed<<setprecision(20);
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N,Q;cin >> N >> Q;

	vector<int> pos;vector<int> cs;

	REP(q,Q){
		char x;ll t;int y,z;
		cin >> x >>t >>y >> z;

		if(x=='R'){
			pos.push_back(pmod(y-t,2*N));
			cs.push_back(z);
		}
		if(x=='L'){
			pos.push_back(pmod(N+(N-1-y)-t,2*N));
			cs.push_back(z);
		}
		if(x=='C'){
			int ry=y,rz=z,ly=N+(N-1-y),lz=N+(N-1-z);
			ry=pmod(ry-t,2*N);rz=pmod(rz-t,2*N);ly=pmod(ly-t,2*N);lz=pmod(lz-t,2*N);
			if(rz<=ry)rz+=2*N;if(ly<=lz)ly+=2*N;

			ll res=0;
			for(int q2=0;q2<pos.size();q2++){
				if(IN(ry,pos[q2],rz) || IN(ry,pos[q2]+2*N,rz) || IN(lz+1,pos[q2],ly+1) || IN(lz+1,pos[q2]+2*N,ly+1))res+=cs[q2];
			}
			cout << res <<endl;
		}
	}
	return 0;
}
0