Submission #653364

#TimeUsernameProblemLanguageResultExecution timeMemory
653364AntekbBalloons (CEOI11_bal)C++14
Compilation error
0 ms0 KiB
#include<bits/stdc++.h>
 
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("trapv")
 
#define st first
#define nd second
#define pb push_back
#define pp pop_back
#define eb emplace_back
#define mp(a, b) make_pair(a, b)
#define all(x) (x).begin(), (x).end()
#define rev(x) reverse(all(x))
#define sor(x) sort(all(x))
#define sz(x) (int)(x).size()
#define rsz(x) resize(x)
 
using namespace std;
 
///~~~~~~~~~~~~~~~~~~~~~~~~~~
 
template <typename H, typename T> 
ostream& operator<<(ostream& os, pair<H, T> m){
	return os <<"("<< m.st<<", "<<m.nd<<")";
}
template <typename H> 
ostream& operator<<(ostream& os, vector<H> V){
	os<<"{";
	for(int i=0; i<V.size(); i++){
		if(i)os<<" ";
		os<<V[i];
	}
	os<<"}";
	return os;
}
 
void debug(){cerr<<"\n";}
template <typename H, typename... T>
void debug(H h, T... t) {cerr<<h; if (sizeof...(t)) cerr << ", "; debug(t...);}
#define deb(x...) cerr<<#x<<" = ";debug(x);
 
///~~~~~~~~~~~~~~~~~~~~~~~~~
 
typedef long long ll;
typedefb double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<pii > vii;
typedef vector<ll> vl;
typedef vector<pll> vll;
typedef string str;
 
#define BOOST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
 
const int N=2e5+5, mod=1e9+7;
const ld INF=1e9, EPS=1e-4;
struct line{
	ld a, b;
	line(ld a, ld b): a(a), b(b){}
	ld isect(line L){
		return (b-L.b)/(L.a-a);
	}
	ld val(ld x){return a*x+b;}
};

struct node{
	node *L=nullptr, *R=nullptr;
	line li=line(0, INF);
	ld l=0, r=INF;
	node(ld l, ld r): l(l), r(r){}
	vector<pair<line, pair<ld, ld> > > todo;
	void insert(line li2, ld l1, ld r1){
		//deb(l, r, li.a, li.b);
		//deb(l1, r1, li2.a, li2.b);
		if(r1<l1+EPS)return;
		if(li2.val(l)>li.val(l)-EPS && li2.val(r)>li.val(r)-EPS)return;
		//deb("a");
		if(l1==l && r1==r && li2.val(l)<li.val(l) && li2.val(r)<li.val(r)){
			li=li2;
			return;
		}
		ld m=(l+r)/2;
		if(L==nullptr){
			L=new node(l, m);
			R=new node(m, r);
		}
		if(l1<=m)L->todo.pb({li2, {l1, min(r1, m)}});
		if(r1>=m)R->todo.pb({li2, {max(l1, m), r1}});
		return;
	}
	ld val(ld x){
		ld ans=li.val(x);
		if(todo.size()<500){
			for(auto &i:todo){
				if(x>=i.nd.st-EPS && x<=i.nd.nd+EPS)ans=min(ans, i.st.val(x));
			}
		}
		else{
			for(auto &i:todo){
				insert(i.st, i.nd.st, i.nd.nd);
			}
			todo.clear();
		}
		ans=min(ans, li.val(x));
		ld m=(l+r)/2;
		if(x<m && L)ans=min(ans, L->val(x));
		else{
			if(R)ans=min(ans, R->val(x));
		}
		return ans;
	}
};
int main(){
	//BOOST;
	int n;
	cin>>n;
	node *root=new node(0, INF);
	for(int i=0; i<n; i++){
		int x, r;
		cin>>x>>r;
		ld r2=root->val(x);
		r2=min(r2*r2, ld(r));
		cout<<fixed<<setprecision(3)<<r2<<"\n";
		if(r2>EPS){
		root->insert(line(-1/ld(2*sqrt(r2)), x/ld(2*sqrt(r2))), 0, x);
		root->insert(line(1/ld(2*sqrt(r2)), -x/ld(2*sqrt(r2))), x, INF);
		}
	}
}

Compilation message (stderr)

bal.cpp:45:1: error: 'typedefb' does not name a type
   45 | typedefb double ld;
      | ^~~~~~~~
bal.cpp:59:7: error: 'ld' does not name a type; did you mean 'll'?
   59 | const ld INF=1e9, EPS=1e-4;
      |       ^~
      |       ll
bal.cpp:61:2: error: 'ld' does not name a type; did you mean 'll'?
   61 |  ld a, b;
      |  ^~
      |  ll
bal.cpp:62:9: error: expected ')' before 'a'
   62 |  line(ld a, ld b): a(a), b(b){}
      |      ~  ^~
      |         )
bal.cpp:63:2: error: 'ld' does not name a type; did you mean 'll'?
   63 |  ld isect(line L){
      |  ^~
      |  ll
bal.cpp:66:2: error: 'ld' does not name a type; did you mean 'll'?
   66 |  ld val(ld x){return a*x+b;}
      |  ^~
      |  ll
bal.cpp:72:2: error: 'ld' does not name a type; did you mean 'll'?
   72 |  ld l=0, r=INF;
      |  ^~
      |  ll
bal.cpp:73:9: error: expected ')' before 'l'
   73 |  node(ld l, ld r): l(l), r(r){}
      |      ~  ^~
      |         )
bal.cpp:74:25: error: 'ld' was not declared in this scope; did you mean 'li'?
   74 |  vector<pair<line, pair<ld, ld> > > todo;
      |                         ^~
      |                         li
bal.cpp:74:29: error: 'ld' was not declared in this scope; did you mean 'li'?
   74 |  vector<pair<line, pair<ld, ld> > > todo;
      |                             ^~
      |                             li
bal.cpp:74:31: error: template argument 1 is invalid
   74 |  vector<pair<line, pair<ld, ld> > > todo;
      |                               ^
bal.cpp:74:31: error: template argument 2 is invalid
bal.cpp:74:33: error: template argument 2 is invalid
   74 |  vector<pair<line, pair<ld, ld> > > todo;
      |                                 ^
bal.cpp:74:35: error: template argument 1 is invalid
   74 |  vector<pair<line, pair<ld, ld> > > todo;
      |                                   ^
bal.cpp:74:35: error: template argument 2 is invalid
bal.cpp:75:24: error: 'ld' has not been declared
   75 |  void insert(line li2, ld l1, ld r1){
      |                        ^~
bal.cpp:75:31: error: 'ld' has not been declared
   75 |  void insert(line li2, ld l1, ld r1){
      |                               ^~
bal.cpp:94:2: error: 'ld' does not name a type; did you mean 'll'?
   94 |  ld val(ld x){
      |  ^~
      |  ll
bal.cpp:71:18: error: 'INF' was not declared in this scope
   71 |  line li=line(0, INF);
      |                  ^~~
bal.cpp: In member function 'void node::insert(line, int, int)':
bal.cpp:78:12: error: 'EPS' was not declared in this scope
   78 |   if(r1<l1+EPS)return;
      |            ^~~
bal.cpp:79:10: error: 'struct line' has no member named 'val'
   79 |   if(li2.val(l)>li.val(l)-EPS && li2.val(r)>li.val(r)-EPS)return;
      |          ^~~
bal.cpp:79:14: error: 'l' was not declared in this scope
   79 |   if(li2.val(l)>li.val(l)-EPS && li2.val(r)>li.val(r)-EPS)return;
      |              ^
bal.cpp:79:20: error: 'struct line' has no member named 'val'
   79 |   if(li2.val(l)>li.val(l)-EPS && li2.val(r)>li.val(r)-EPS)return;
      |                    ^~~
bal.cpp:79:27: error: 'EPS' was not declared in this scope
   79 |   if(li2.val(l)>li.val(l)-EPS && li2.val(r)>li.val(r)-EPS)return;
      |                           ^~~
bal.cpp:79:38: error: 'struct line' has no member named 'val'
   79 |   if(li2.val(l)>li.val(l)-EPS && li2.val(r)>li.val(r)-EPS)return;
      |                                      ^~~
bal.cpp:79:42: error: 'r' was not declared in this scope
   79 |   if(li2.val(l)>li.val(l)-EPS && li2.val(r)>li.val(r)-EPS)return;
      |                                          ^
bal.cpp:79:48: error: 'struct line' has no member named 'val'
   79 |   if(li2.val(l)>li.val(l)-EPS && li2.val(r)>li.val(r)-EPS)return;
      |                                                ^~~
bal.cpp:81:10: error: 'l' was not declared in this scope
   81 |   if(l1==l && r1==r && li2.val(l)<li.val(l) && li2.val(r)<li.val(r)){
      |          ^
bal.cpp:81:19: error: 'r' was not declared in this scope
   81 |   if(l1==l && r1==r && li2.val(l)<li.val(l) && li2.val(r)<li.val(r)){
      |                   ^
bal.cpp:81:28: error: 'struct line' has no member named 'val'
   81 |   if(l1==l && r1==r && li2.val(l)<li.val(l) && li2.val(r)<li.val(r)){
      |                            ^~~
bal.cpp:81:38: error: 'struct line' has no member named 'val'
   81 |   if(l1==l && r1==r && li2.val(l)<li.val(l) && li2.val(r)<li.val(r)){
      |                                      ^~~
bal.cpp:81:52: error: 'struct line' has no member named 'val'
   81 |   if(l1==l && r1==r && li2.val(l)<li.val(l) && li2.val(r)<li.val(r)){
      |                                                    ^~~
bal.cpp:81:62: error: 'struct line' has no member named 'val'
   81 |   if(l1==l && r1==r && li2.val(l)<li.val(l) && li2.val(r)<li.val(r)){
      |                                                              ^~~
bal.cpp:85:3: error: 'ld' was not declared in this scope; did you mean 'li'?
   85 |   ld m=(l+r)/2;
      |   ^~
      |   li
bal.cpp:87:15: error: 'l' was not declared in this scope
   87 |    L=new node(l, m);
      |               ^
bal.cpp:87:18: error: 'm' was not declared in this scope
   87 |    L=new node(l, m);
      |                  ^
bal.cpp:88:18: error: 'r' was not declared in this scope
   88 |    R=new node(m, r);
      |                  ^
bal.cpp:90:10: error: 'm' was not declared in this scope
   90 |   if(l1<=m)L->todo.pb({li2, {l1, min(r1, m)}});
      |          ^
bal.cpp:8:12: error: request for member 'push_back' in '((node*)this)->node::L->node::todo', which is of non-class type 'int'
    8 | #define pb push_back
      |            ^~~~~~~~~
bal.cpp:90:20: note: in expansion of macro 'pb'
   90 |   if(l1<=m)L->todo.pb({li2, {l1, min(r1, m)}});
      |                    ^~
bal.cpp:91:10: error: 'm' was not declared in this scope
   91 |   if(r1>=m)R->todo.pb({li2, {max(l1, m), r1}});
      |          ^
bal.cpp:8:12: error: request for member 'push_back' in '((node*)this)->node::R->node::todo', which is of non-class type 'int'
    8 | #define pb push_back
      |            ^~~~~~~~~
bal.cpp:91:20: note: in expansion of macro 'pb'
   91 |   if(r1>=m)R->todo.pb({li2, {max(l1, m), r1}});
      |                    ^~
bal.cpp: In function 'int main()':
bal.cpp:120:25: error: 'INF' was not declared in this scope
  120 |  node *root=new node(0, INF);
      |                         ^~~
bal.cpp:124:3: error: 'ld' was not declared in this scope; did you mean 'll'?
  124 |   ld r2=root->val(x);
      |   ^~
      |   ll
bal.cpp:125:3: error: 'r2' was not declared in this scope; did you mean 'r'?
  125 |   r2=min(r2*r2, ld(r));
      |   ^~
      |   r
bal.cpp:127:9: error: 'EPS' was not declared in this scope
  127 |   if(r2>EPS){
      |         ^~~