Submission #653953

# Submission time Handle Problem Language Result Execution time Memory
653953 2022-10-29T04:17:24 Z guagua0407 trapezoid (balkan11_trapezoid) C++17
14 / 100
354 ms 53376 KB
/*
希望能進全國賽
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<ll,ll>
#define f first
#define s second
#define all(x) x.begin(),x.end()
#define _ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

void setIO(string s) {
	freopen((s + ".in").c_str(), "r", stdin);
	freopen((s + ".out").c_str(), "w", stdout);
}

struct node{
	ll a,b,c,d;
};

const ll mxn=2e5+5;
node num[mxn];
vector<pair<ll,ll>> as[mxn],bs[mxn];
pair<ll,ll> ans[mxn];
pair<ll,ll> segtree[mxn*4];
map<ll,ll> idup,iddown;
ll cntup=0;
ll cntdown=0;

pii comb(pii a,pii b){
	if(a.f==b.f){
		return {a.f,a.s+b.s};
	}
	return max(a,b);
}

void update(ll pos,pii val,ll l=1,ll r=cntdown,ll v=1){
	if(l==r){
		segtree[v]=comb(segtree[v],val);
		return;
	}
	ll mid=(l+r)/2;
	if(pos<=mid) update(pos,val,l,mid,v*2);
	else update(pos,val,mid+1,r,v*2+1);
	segtree[v]=comb(segtree[v*2],segtree[v*2+1]);
}

pair<ll,ll> query(ll tl,ll tr,ll l=1,ll r=cntdown,ll v=1){
	if(tl>tr){
		return {0,0};
	}
	if(tl<=l and r<=tr){
		return segtree[v];
	}
	ll mid=(l+r)/2;
	return comb(query(tl,min(mid,tr),l,mid,v*2),query(max(mid+1,tl),tr,mid+1,r,v*2+1));
}

int main() {_
	//setIO("wayne");
	ll n;
	cin>>n;
	for(ll i=1;i<=n;i++){
		ll a,b,c,d;
		cin>>a>>b>>c>>d;
		num[i]={a,b,c,d};
		idup[a]++;
		idup[b]++;
		iddown[c]++;
		iddown[d]++;
	}
	for(auto &v:idup){
		cntup++;
		v.s=cntup;
	}
	for(auto &v:iddown){
		cntdown++;
		v.s=cntdown;
	}
	for(ll i=1;i<=n;i++){
		as[idup[num[i].a]].push_back({iddown[num[i].c],i});
		bs[idup[num[i].b]].push_back({iddown[num[i].d],i});
	}
	for(ll i=1;i<=cntup;i++){
		for(auto v:as[i]){
			//cout<<"a "<<v.s<<'\n';
			pii tmp=query(1,v.f-1);
			ans[v.s]={tmp.f+1,tmp.s+(tmp.f==0)};
		}
		for(auto v:bs[i]){
			//cout<<"b "<<v.s<<'\n';
			update(v.f,ans[v.s]);
		}
		//cout<<'\n';
	}
	cout<<segtree[1].f<<' '<<segtree[1].s<<'\n';
	return 0;
}
//maybe its multiset not set

Compilation message

trapezoid.cpp: In function 'void setIO(std::string)':
trapezoid.cpp:14:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |  freopen((s + ".in").c_str(), "r", stdin);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
trapezoid.cpp:15:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |  freopen((s + ".out").c_str(), "w", stdout);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 6 ms 9684 KB Output is correct
2 Correct 6 ms 9728 KB Output is correct
3 Incorrect 6 ms 9940 KB Expected int32, but "10313130667392" found
4 Incorrect 7 ms 10068 KB Expected int32, but "-8550276992825950208" found
5 Partially correct 10 ms 10580 KB Partially correct
6 Incorrect 11 ms 11000 KB Expected int32, but "-8629080777422869056" found
7 Incorrect 13 ms 11348 KB Expected int32, but "-3319866744691032064" found
8 Partially correct 19 ms 12040 KB Partially correct
9 Incorrect 29 ms 14316 KB Expected int32, but "2248786528710863832" found
10 Incorrect 55 ms 18900 KB Expected int32, but "-5022802232222890496" found
11 Incorrect 76 ms 20512 KB Expected int32, but "-1298419000938405298" found
12 Incorrect 161 ms 31704 KB Expected int32, but "9183932486774365824" found
13 Incorrect 208 ms 35404 KB Expected int32, but "-4195152448689438272" found
14 Incorrect 241 ms 42676 KB Expected int32, but "-3175106568905838848" found
15 Incorrect 302 ms 44960 KB Expected int32, but "-8026369531311511552" found
16 Incorrect 354 ms 46568 KB Expected int32, but "6233362917342126368" found
17 Incorrect 306 ms 48504 KB Expected int32, but "-7505826292837535760" found
18 Incorrect 256 ms 50036 KB Expected int32, but "-6197299359079266322" found
19 Incorrect 296 ms 50564 KB Expected int32, but "5619696618904563712" found
20 Incorrect 340 ms 53376 KB Expected int32, but "-335818733633578353" found