結果
| 問題 |
No.5020 Averaging
|
| コンテスト | |
| ユーザー |
FplusFplusF
|
| 提出日時 | 2024-02-25 13:35:06 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,997 bytes |
| コンパイル時間 | 2,964 ms |
| コンパイル使用メモリ | 254,588 KB |
| 実行使用メモリ | 6,676 KB |
| スコア | 0 |
| 最終ジャッジ日時 | 2024-02-25 13:35:12 |
| 合計ジャッジ時間 | 4,731 ms |
|
ジャッジサーバーID (参考情報) |
judge15 / judge12 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | WA * 50 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;
using tii=tuple<int,int,int>;
using qii=tuple<int,int,int,int>;
using ll=long long;
using ld=long double;
const ll INF=1ll<<60;
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
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;
}
auto program_start=chrono::system_clock::now();
mt19937 mt;
int rand_int(int r){ //[0,r)
return mt()%r;
}
int rand_int(int l,int r){ //[l,r)
return l+mt()%(r-l);
}
double rand_double(){ //[0.0,1.0]
return (double)mt()/(double)mt19937::max();
}
const ll C=5e17;
int N;
vector<ll> A,B;
namespace Solver{
int score(vector<pii> &ans){
vector<ll> a=A,b=B;
for(auto [u,v]:ans){
a[v]=a[u]=(a[u]+a[v])/2;
b[v]=b[u]=(b[u]+b[v])/2;
}
return floorl(2000000.0-100000.0*log10l(max(abs(C-a[0]),abs(C-b[0]))+1));
}
void solve(){
vector<ll> a=A,b=B;
vector<pii> ans;
while((int)ans.size()<50){
ll mn=INF;
int idx=-1;
for(int i=1;i<N;i++){
ll x=abs(C-(a[0]+a[i])/2),y=abs(C-(b[0]+b[i])/2);
if(chmin(mn,x+y)) idx=i;
}
ll pre_score=abs(C-a[0])+abs(C-b[0]);
a[0]=(a[0]+a[idx])/2;
a[idx]=a[0];
b[0]=(b[0]+b[idx])/2;
b[idx]=b[0];
ll new_score=abs(C-a[0])+abs(C-b[0]);
if(pre_score<=new_score) break;
ans.emplace_back(0,idx);
}
cout << (int)ans.size() << '\n';
for(auto [u,v]:ans) cout << u << ' ' << v << '\n';
}
}
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> N;
A.resize(N);
B.resize(N);
rep(i,N) cin >> A[i] >> B[i];
Solver::solve();
}
FplusFplusF