結果
| 問題 |
No.2873 Kendall's Tau
|
| コンテスト | |
| ユーザー |
FplusFplusF
|
| 提出日時 | 2024-09-06 22:23:48 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 1,168 ms / 4,500 ms |
| コード長 | 1,746 bytes |
| コンパイル時間 | 5,251 ms |
| コンパイル使用メモリ | 298,440 KB |
| 実行使用メモリ | 41,008 KB |
| 最終ジャッジ日時 | 2024-09-06 22:24:14 |
| 合計ジャッジ時間 | 20,769 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 30 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ull=unsigned long long;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll,ll>;
using ld=long double;
const ll INF=(1ll<<60);
#define rep(i,n) for (ll i=0;i<(ll)(n);i++)
#define replr(i,l,r) for (ll i=(ll)(l);i<(ll)(r);i++)
#define all(v) v.begin(),v.end()
#define len(v) ((ll)v.size())
template<class T> inline bool chmin(T &a,T b){
if(a>b){
a=b;
return true;
}
return false;
}
template<class T> inline bool chmax(T &a,T b){
if(a<b){
a=b;
return true;
}
return false;
}
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
template<class T> using super_set=__gnu_pbds::tree<T,__gnu_pbds::null_type,std::less<T>,__gnu_pbds::rb_tree_tag,__gnu_pbds::tree_order_statistics_node_update>;
ll f(vector<pll> v){
super_set<tll> stx;
super_set<pll> sty;
ll ret=0;
rep(i,len(v)){
ret+=sty.order_of_key({v[i].second,-INF});
ret-=stx.order_of_key({v[i].first,v[i].second,-INF})-stx.order_of_key({v[i].first,-INF,-INF});
stx.insert({v[i].first,v[i].second,i});
sty.insert({v[i].second,i});
}
return ret;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
ll n;
cin >> n;
vector<ll> x(n),y(n);
vector<pll> v(n);
rep(i,n){
cin >> x[i] >> y[i];
v[i]={x[i],y[i]};
}
sort(all(v));
ll p=f(v);
rep(i,n){
v[i].first*=-1;
}
sort(all(v));
ll q=f(v);
map<ll,ll> cx,cy;
ll r=0,s=0;
rep(i,n){
r+=i-cx[x[i]];
cx[x[i]]++;
s+=i-cy[y[i]];
cy[y[i]]++;
}
cout << fixed << setprecision(10) << (ld)(p-q)/sqrtl((ld)r*s) << '\n';
}
FplusFplusF