結果

問題 No.2462 七人カノン
ユーザー chineristACchineristAC
提出日時 2021-06-01 11:54:51
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 115 ms / 2,000 ms
コード長 2,100 bytes
コンパイル時間 6,119 ms
コンパイル使用メモリ 239,192 KB
実行使用メモリ 12,660 KB
最終ジャッジ日時 2023-09-08 20:50:42
合計ジャッジ時間 12,954 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
7,580 KB
testcase_01 AC 5 ms
7,700 KB
testcase_02 AC 5 ms
7,712 KB
testcase_03 AC 5 ms
7,628 KB
testcase_04 AC 5 ms
7,744 KB
testcase_05 AC 5 ms
7,752 KB
testcase_06 AC 5 ms
7,852 KB
testcase_07 AC 5 ms
7,740 KB
testcase_08 AC 5 ms
7,736 KB
testcase_09 AC 5 ms
7,672 KB
testcase_10 AC 5 ms
7,696 KB
testcase_11 AC 5 ms
7,680 KB
testcase_12 AC 5 ms
7,744 KB
testcase_13 AC 90 ms
11,104 KB
testcase_14 AC 101 ms
11,564 KB
testcase_15 AC 95 ms
11,016 KB
testcase_16 AC 110 ms
11,560 KB
testcase_17 AC 106 ms
11,472 KB
testcase_18 AC 44 ms
9,388 KB
testcase_19 AC 44 ms
9,488 KB
testcase_20 AC 99 ms
12,548 KB
testcase_21 AC 99 ms
12,660 KB
testcase_22 AC 103 ms
12,504 KB
testcase_23 AC 97 ms
12,648 KB
testcase_24 AC 82 ms
11,000 KB
testcase_25 AC 115 ms
12,588 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <random>
#include <stdio.h>
#include <fstream>
#include <functional>
#include <cassert>
#include "testlib.h"
using namespace std;

#define rep(i,n,c) for (int i=0;i<n;i+=c)
#define append push_back
#define all(x) (x).begin(), (x).end()

template<class T>
using vec = vector<T>;
template<class T>
using vvec = vec<vec<T>>;
template<class T>
using vvvec = vec<vvec<T>>;
using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;


template<class T>
bool chmin(T &a, T b){
  if (a>b){
    a = b;
    return true;
  }
  return false;
}

template<class T>
bool chmax(T &a, T b){
  if (a<b){
    a = b;
    return true;
  }
  return false;
}

template<class T>
T sum(vec<T> x){
  T res=0;
  for (auto e:x){
    res += e;
  }
  return res;
}

template<class T>
void printv(vec<T> x){
  for (auto e:x){
    cout<<e<<" ";
  }
  cout<<"\n";
}

int cnt[100001];
long double standout[100001];

int main(int argc, char* argv[]){
  registerValidation(argc,argv);
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);

  cout<<setprecision(10);

  int N,Q;
  int I,S,T;

  N = inf.readInt(1,100000);
  inf.readSpace();
  Q = inf.readInt(1,100000);
  inf.readEoln();

  vec<vec<pii>> play(N,vec<pii>(0));
  for (int i=0;i<Q;i++){
    I = inf.readInt(1,N);
    inf.readSpace();
    S = inf.readInt(0,100000);
    inf.readSpace();
    T = inf.readInt(S+1,100000);
    inf.readEoln();

    I -= 1;
    cnt[S] += 1;
    cnt[T] -= 1;
    play[I].append({S,T});
  }

  inf.readEof();

  for (int t=1;t<100001;t++){
    cnt[t] += cnt[t-1];
  }

  for (int t=0;t<100001;t++){
    if (cnt[t]>0){
      long double k = cnt[t];
      standout[t] = (long double)(1/k);
    }
    if (t>0){
      standout[t] += standout[t-1];
    }
  }

  long double res;
  for (int i=0;i<N;i++){
    res = 0;
    for (auto[s,t]:play[i]){
      res += standout[t-1];
      if (s>0){
        res -= standout[s-1];
      }
    }
    cout<<res<<"\n";
  }
  
  
}
0