結果

問題 No.151 セグメントフィッシング
ユーザー OnjuOnju
提出日時 2015-02-12 23:58:41
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 1,186 ms / 5,000 ms
コード長 1,109 bytes
コンパイル時間 483 ms
コンパイル使用メモリ 64,568 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-06 00:19:18
合計ジャッジ時間 10,612 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,504 KB
testcase_08 AC 43 ms
4,376 KB
testcase_09 AC 44 ms
4,376 KB
testcase_10 AC 44 ms
4,376 KB
testcase_11 AC 43 ms
4,376 KB
testcase_12 AC 967 ms
4,380 KB
testcase_13 AC 951 ms
4,380 KB
testcase_14 AC 966 ms
4,380 KB
testcase_15 AC 972 ms
4,380 KB
testcase_16 AC 962 ms
4,376 KB
testcase_17 AC 174 ms
4,380 KB
testcase_18 AC 176 ms
4,376 KB
testcase_19 AC 204 ms
4,376 KB
testcase_20 AC 207 ms
4,380 KB
testcase_21 AC 1,184 ms
4,376 KB
testcase_22 AC 1,186 ms
4,376 KB
testcase_23 AC 867 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <cstring>
#include <climits>
#include <vector>
#define N_MAX 20000
#define Q_MAX 20000
using namespace std;
typedef unsigned long long ULL;
typedef long long LL;

typedef struct
{
	int pos;
	int num;
	char way;
}Fish;

int main()
{
	int N, Q;
	char x[Q_MAX];
	int y[Q_MAX], z[Q_MAX];

	cin >> N >> Q;
	for (int i = 0; i < Q; ++i)
		cin >> x[i] >> y[i] >> z[i];

	vector<Fish> fish;	
	for (int i = 0; i < Q; ++i)
	{
		for (auto it = fish.begin(); it != fish.end(); ++it)
		{
			if ((*it).way == 'L')
			{
				if ((*it).pos == 0)
					(*it).way = 'R';
				else
					--((*it).pos);
			}
			else
			{
				if ((*it).pos == N-1)
					(*it).way = 'L';
				else
					++((*it).pos);
			}
		}

		LL count = 0;
		switch (x[i])
		{
		case 'L':
			fish.push_back(Fish{ y[i], z[i], 'L' });
			break;
		case 'R':
			fish.push_back(Fish{ y[i], z[i], 'R' });
			break;
		case 'C':
			for (auto it = fish.begin(); it != fish.end(); ++it)
			{
				if ((*it).pos >= y[i] && (*it).pos < z[i])
					count += (*it).num;
			}
			cout << count << endl;

			break;
		}
	}

	return 0;
}
0