Submission #556977

#TimeUsernameProblemLanguageResultExecution timeMemory
556977uroskNautilus (BOI19_nautilus)C++14
0 / 100
14 ms340 KiB
// __builtin_popcount(x) broj bitova // __builtin_popcountll(x) // __builtin_clz(x) vodece nule // __builtin_clzll(x) // __builtin_ctz(x) nule na pocetku // __builtin_ctzll(x) // 2000000011 // 2000000033 #include "bits/stdc++.h" #include <ext/pb_ds/tree_policy.hpp> #include <ext/pb_ds/assoc_container.hpp> #define ld double #define ll int #define ull unsigned long long #define llinf 100000000000000000LL // 10^17 #define iinf 2000000000 // 2*10^9 #define pb push_back #define popb pop_back #define fi first #define sc second #define endl '\n' #define pii pair<int,int> #define pll pair<ll,ll> #define pld pair<ld,ld> #define sz(a) ((ll)(a.size())) #define all(a) a.begin(),a.end() #define rall(a) a.begin(),a.end(),greater<int>() #define getunique(v) {sort(all(v)); v.erase(unique(all(v)), v.end());} #define pi 3.14159265358979323846 #define here cerr<<"=============================================================================\n" #define ceri(a,l,r) {for(ll i = l;i<=r;i++) cerr<<a[i]<< " ";cerr<<endl;} #define ceri2(a,l,r,n,m) {for(ll i = l;i<=r;i++){for(ll j = n;j<=m;j++) cerr<<a[i][j]<< " ";cerr<<endl;}} #define yes cout<<"YES"<<endl #define no cout<<"NO"<<endl #define daj_mi_malo_vremena ios_base::sync_with_stdio(false);cerr.tie(0);cout.tie(0);cin.tie(0); using namespace std; using namespace __gnu_pbds; typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset; mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); ll rnd(ll l,ll r){ return uniform_int_distribution<ll>(l,r)(rng); } void setIO(string inoutname) { freopen((inoutname+".in").c_str(),"r",stdin); freopen((inoutname+".out").c_str(),"w",stdout); } #define mod 1 ll gcd(ll a, ll b) { if(b==0) return a; if(a==0) return b; if(a>=b) return gcd(a%b,b); return gcd(a,b%a); } ll lcm(ll a,ll b){ return (a/gcd(a,b))*b; } ll add(ll x,ll y){ x+=y; if(x<0){ x%=mod; x+=mod; }else{ if(x>=mod) x%=mod; } return x; } ll mul(ll a,ll b){ ll ans = (a*b)%mod; if(ans<0) ans+=mod; return ans; } ll po(ll x,ll y){ if(y==0) return 1LL; ll ans = po(x,y/2); ans = mul(ans,ans); if(y&1) ans = mul(ans,x); return ans; } ll inv(ll x){return po(x,mod-2);} #define maxn 50005 ll n; vector<pll> a; vector<pll> b; ll cross(pll a,pll b,pll c){ return (b.fi-a.fi)*(c.sc-a.sc)-(c.fi-a.fi)*(b.sc-a.sc); } vector<pll> gethull(vector<pll> c){ vector<pll> hull; sort(all(c)); if(sz(c)==1) return c; bool col = 1; for(ll i = 0;i+2<sz(c);i++){ if(cross(c[i],c[i+1],c[i+2])!=0) col = 0; } if(col) return {c[0],c.back()}; for(ll iii = 0;iii<2;iii++){ ll sizi = sz(hull); for(ll i = 0;i<n;i++){ pll z = c[i]; while(sz(hull)>=sizi+2){ pll y = hull[sz(hull)-1]; pll x = hull[sz(hull)-2]; if(cross(x,y,z)<0) break; hull.popb(); } hull.pb(z); } hull.popb(); reverse(all(c)); } return c; } pll p; bool cmp(pll a,pll b){ return cross(p,a,b)>0; } ll reshi(vector<pll> a,vector<pll> b){ vector<pll> hull = gethull(a); sort(all(hull)); pll p = hull[0]; sort(hull.begin()+1,hull.end(),cmp); hull.pb(p); ll ans = 0; here; for(pll p : hull){ cerr<<p.fi<< " "<<p.sc<<endl; } cerr<<"ima: "<<endl; for(pll q : b){ ll l = 1,r = n-1,mid,rez = -1; cerr<<q.fi<< " "<<q.sc<<" "<<endl; while(l<=r){ mid = (l+r)/2; cerr<<mid<< " "<<hull[mid].fi<< " "<<hull[mid].sc<<endl; if(cross(p,hull[mid],q)>0){ rez = mid; r = mid-1; }else l = mid+1; } cerr<<rez<<endl; if(rez==-1) continue; if(cross(hull[rez],hull[rez+1],q)>0&&cross(hull[rez+1],p,q)>0){ ans++; cerr<<"da"<<endl; }else cerr<<"ne"<<endl; } return ans; } void tc(){ cin >> n; for(ll i = 1;i<=n;i++){pll p; cin >> p.fi >> p.sc; a.pb(p);} for(ll i = 1;i<=n;i++){pll p; cin >> p.fi >> p.sc; b.pb(p);} cout<<reshi(a,b)<< " "<<reshi(b,a)<<endl; } int main(){ daj_mi_malo_vremena //setIO("lol"); int t; t = 1; while(t--){ tc(); } return 0; }

Compilation message (stderr)

nautilus.cpp: In function 'void setIO(std::string)':
nautilus.cpp:48:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   48 |  freopen((inoutname+".in").c_str(),"r",stdin);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
nautilus.cpp:49:13: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   49 |      freopen((inoutname+".out").c_str(),"w",stdout);
      |      ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...