제출 #1332400

#제출 시각아이디문제언어결과실행 시간메모리
1332400mrbetBalloons (CEOI11_bal)C++17
20 / 100
195 ms6696 KiB
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define forr(_a,_b,_c) for(int _a = (_b); _a <= int (_c); ++_a)
#define ford(_a,_b,_c) for(int _a = (_b) + 1; _a --> int (_c);)
#define forf(_a,_b,_c) for(int _a = (_b); _a < int (_c); ++_a)
#define pb push_back
#define fi first
#define se second
#define vi vector
#define all(_v) _v.begin(), _v.end()
#define mask(_x) (1ll << (_x))
#define bit(_x,_y) (((_x) >> (_y)) & 1)
#define file "A"

string yes[2] = {"NO\n","YES\n"};
const ld eps = ld(1e-7);
const ll inf = ll(1e16) + 1;
const ll mod = ll(1e9) + 7;

template<class X, class Y>
inline bool Min(X &x, const Y &y) {
  if(x > y) {
    x = y;
    return true;
  }
  return false;
}

template<class X, class Y>
inline bool Max(X &x, const Y &y) {
  if(x < y) {
    x = y;
    return true;
  }
  return false;
}

const int N = 2e5+5;

int n;
pii a[N];
stack<int> s;
ld rad_i[N];

ld calc_dis(ld x1,ld y1,ld x2,ld y2) {
    ld dx= x1-x2;
    ld dy= y1-y2;

    return sqrt(dx*dx+dy*dy);
}

bool check(ld cur_coor,ld cur_rad) {
    ld rad= rad_i[s.top()];
    ld coor= a[s.top()].fi;
  //  cout<<cur_coor<<' '<<cur_rad<<' '<<coor<<' '<<rad<<'\n';
    ld dis= calc_dis(cur_coor,cur_rad,coor,rad);
  //  cout<<dis<<' '<<rad+cur_rad<<'\n';

    return dis>=rad+cur_rad;
}

void Mei () {
    cin>>n;
    forr(i,1,n) cin>>a[i].fi>>a[i].se;

    s.push(1);
    rad_i[1]=a[1].se;

    forr(i,2,n) {
        ld l=0, r= a[i].se, ans=0.0;
       //  cnp tim ban kinh lon nhat tiep xuc hinh tron s.top()
        while (r-l>eps) {
            ld mid= (l+r) /2;
            if (check(a[i].fi,mid)) {
                ans=mid;
                l=mid;
            }
            else r=mid;
        }
        rad_i[i]=ans;
        while (s.size() && rad_i[s.top()]+a[s.top()].fi<= rad_i[i]+a[i].fi) s.pop();
        if (s.empty()) s.push(i);
     //   cout<<s.top()<<'\n';
    }

    forr(i,1,n) cout<<rad_i[i]<<' ';
}

void precalc() {
}

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  cout << fixed << setprecision(3);

  if (fopen(file".inp","r")) {
    freopen(file".inp","r",stdin); freopen(file".out","w",stdout);
  }
  else if (fopen(file".in","r")) {
    freopen(file".in","r",stdin); freopen(file".out","w",stdout);
  }

  int tc = 1;
 // cin >> tc;
  precalc();
  while(tc--) {
    Mei();
  }

  return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

bal.cpp: In function 'int main()':
bal.cpp:102:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  102 |     freopen(file".inp","r",stdin); freopen(file".out","w",stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
bal.cpp:102:43: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  102 |     freopen(file".inp","r",stdin); freopen(file".out","w",stdout);
      |                                    ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
bal.cpp:105:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  105 |     freopen(file".in","r",stdin); freopen(file".out","w",stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~
bal.cpp:105:42: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  105 |     freopen(file".in","r",stdin); freopen(file".out","w",stdout);
      |                                   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...