Submission #255814

#TimeUsernameProblemLanguageResultExecution timeMemory
255814uacoder123Examination (JOI19_examination)C++14
0 / 100
2307 ms234548 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> using namespace std; using namespace __gnu_pbds; #define F first #define S second #define FOR(i,a,b) for (auto i = (a); i <= (b); ++i) #define NFOR(i,a,b) for(auto i = (a); i >= (b); --i) #define all(x) (x).begin(), (x).end() #define sz(x) int(x.size()) #define mp(i,a) make_pair(i,a) #define pb(a) push_back(a) #define bit(x,b) (x&(1LL<<b)) typedef long long int lli; typedef pair <lli,lli> ii; typedef pair <lli,ii> iii; typedef vector <lli> vi; typedef tree< ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; ordered_set segt[8*100000+1]; int n,q; void up(int node,int l,int r,int in,int v) { segt[node].insert(mp(v,q+1)); int m=(l+r)/2; if(l!=r) { if(in<=m) up(2*node+1,l,m,in,v); else up(2*node+2,m+1,r,in,v); } } int query(int node,int l,int r,int s,int e,int v) { if(r<s||l>e) return(0); if(l>=s&&r<=e) return segt[node].size()-segt[node].order_of_key(mp(v,0)); int m=(l+r)/2; int q1=query(2*node+1,l,m,s,e,v),q2=query(2*node+2,m+1,r,s,e,v); return(q1+q2); } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin>>n>>q; multiset<pair<ii,ii>> se; set<int> v; unordered_map<int,int> m; ii s[n]; pair<ii,int> qu[q]; for(int i=0;i<n;++i) { cin>>s[i].F>>s[i].S; v.insert(s[i].F); v.insert(s[i].S); v.insert(s[i].F+s[i].S); } for(int i=0;i<q;++i) { cin>>qu[i].F.F>>qu[i].F.S>>qu[i].S; v.insert(qu[i].F.F); v.insert(qu[i].F.S); v.insert(qu[i].S); } auto it=v.begin(); int c=0,c1=0; while(it!=v.end()) { m[(*it)]=c; c++; it++; } for(int i=0;i<n;++i) { int su=s[i].F+s[i].S; s[i].F=m[s[i].F]; s[i].S=m[s[i].S]; se.insert(mp(mp(s[i].F,s[i].S),mp(q+11,m[su]))); } for(int i=0;i<q;++i) { qu[i].F.S=m[qu[i].F.S]; qu[i].F.F=m[qu[i].F.F]; qu[i].S=m[qu[i].S]; se.insert(mp(mp(qu[i].F.F,qu[i].F.S),mp(i,qu[i].S))); } auto it1=se.begin(); vector<ii> st[c]; vector<iii> que[c]; while(it1!=se.end()) { int in=(*it1).S.S; if((*it1).S.F!=q+11) que[in].pb(mp((*it1).S.F,mp(c1,(*it1).F.S))); else st[in].pb(mp(c1,(*it1).F.S)); it1++; c1++; } int ans[q]={}; for(int i=c-1;i>=0;--i) { for(int j=0;j<st[i].size();++j) up(0,0,c1-1,st[i][j].F,st[i][j].S); for(int j=0;j<que[i].size();++j) ans[que[i][j].F]=query(0,0,c1-1,que[i][j].S.F,c1-1,que[i][j].S.S); } for(int i=0;i<q;++i) cout<<ans[i]<<endl; return(0); }

Compilation message (stderr)

examination.cpp: In function 'int main()':
examination.cpp:113:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int j=0;j<st[i].size();++j)
                 ~^~~~~~~~~~~~~
examination.cpp:115:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int j=0;j<que[i].size();++j)
                 ~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...