結果

問題 No.2462 七人カノン
ユーザー anago-pieanago-pie
提出日時 2023-09-08 23:13:26
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 585 ms / 2,000 ms
コード長 1,165 bytes
コンパイル時間 2,426 ms
コンパイル使用メモリ 192,320 KB
実行使用メモリ 33,488 KB
最終ジャッジ日時 2023-09-08 23:13:41
合計ジャッジ時間 14,441 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 3 ms
4,380 KB
testcase_03 AC 8 ms
4,376 KB
testcase_04 AC 6 ms
4,380 KB
testcase_05 AC 6 ms
4,376 KB
testcase_06 AC 7 ms
4,380 KB
testcase_07 AC 7 ms
4,376 KB
testcase_08 AC 6 ms
4,380 KB
testcase_09 AC 6 ms
4,376 KB
testcase_10 AC 7 ms
4,380 KB
testcase_11 AC 7 ms
4,380 KB
testcase_12 AC 7 ms
4,376 KB
testcase_13 AC 492 ms
26,528 KB
testcase_14 AC 553 ms
27,108 KB
testcase_15 AC 499 ms
25,936 KB
testcase_16 AC 574 ms
28,388 KB
testcase_17 AC 583 ms
28,188 KB
testcase_18 AC 174 ms
7,140 KB
testcase_19 AC 171 ms
6,992 KB
testcase_20 AC 357 ms
18,828 KB
testcase_21 AC 347 ms
18,732 KB
testcase_22 AC 380 ms
18,840 KB
testcase_23 AC 345 ms
18,784 KB
testcase_24 AC 422 ms
28,316 KB
testcase_25 AC 585 ms
33,488 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <iterator>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define debug 1
using ll = long long;
using ld = long double;
const int mod = 998244353;
const double pi = atan2(0, -1);
#include <time.h>
#include <chrono>

int main() {
	int N, Q;
	cin >> N >> Q;
	vector<double> ans(N + 1, 0);
	set<int> list;
	map<int, vector<int>> mp;
	unordered_set<int> play;
	vector<vector<vector<int>>> ord(N + 1);
	int sum = 0;
	int now = 0;
	vector<double> tl(100002);
	rep(i, Q) {
		int p, s, t;
		cin >> p >> s >> t;
		s++;
		t++;
		list.insert(s);
		list.insert(t);
		mp[s].push_back(p);
		mp[t].push_back(p);
		ord[p].push_back({ s,t });
	}
	for(int time = 1; time < 100002;time++) {
		if (list.count(time)) {
			for (int x : mp[time]) {
				if (play.count(x)) {
					play.erase(x);
					sum--;
				}
				else {
					play.insert(x);
					sum++;
				}
			}
		}
		if (sum >= 1) {
			tl[time] = (double)1 / (double)sum;
		}
		tl[time] += tl[time - 1];
	}
	for (int i = 1; i <= N; i++) {
		for (vector<int> v : ord[i]) {
			ans[i] += tl[v[1]-1] - tl[v[0] - 1];
		}
		cout << fixed << setprecision(10);
		cout << ans[i] << endl;
	}
}
0