Submission #106230

#TimeUsernameProblemLanguageResultExecution timeMemory
106230abilExamination (JOI19_examination)C++14
0 / 100
3023 ms8036 KiB
#include <bits/stdc++.h> #define int long long #define mk make_pair #define sc second #define fr first #define pb emplace_back #define all(s) s.begin(), s.end() #define sz(s) ( (int)s.size() ) #define Scan(a) scanf ("%I64d", &a) #define scan(a) scanf ("%d", &a) using namespace std; const long long INF = (int)1e18 + 7; const int N = (int)3e5 + 7; const int mod = 1000000007; int n, q, s[N], t[N]; vector<pair<pair<int,int >,int >> v,w; bool cmp(const pair<pair<int,int >,int > &x, const pair<pair<int,int >,int > &y){ if(x.fr.fr == y.fr.fr){ return x.fr.sc < y.fr.sc; } else{ return x.fr.fr < y.fr.fr; } } bool cmp1(const pair<pair<int,int >,int > &x, const pair<pair<int,int >,int > &y){ if(x.fr.sc == y.fr.sc){ return x.sc < y.sc; } else{ return x.fr.sc < y.fr.sc; } } bool cmp2(const pair<pair<int,int >,int > &x, const pair<pair<int,int >,int > &y){ return x.sc < y.sc; } main(){ cin >> n >> q; for(int i = 1;i <= n; i++){ Scan(s[i]); Scan(t[i]); v.pb(mk(mk(s[i] + t[i],s[i]),t[i])); } sort(all(v),cmp); int a, b, c; while(q--){ Scan(a); Scan(b); Scan(c); w = v; int l = 0, r = n - 1; while(r - l > 1){ int mid = (r + l) >> 1; if(w[mid].fr.fr >= c){ r = mid; } else{ l = mid; } } if(w[l].fr.fr >= c){ r = l; } sort(w.begin() + r,w.end(),cmp1); l = r, r = n - 1; while(r - l > 1){ int mid = (r + l) >> 1; if(w[mid].fr.sc >= a){ r = mid; } else{ l = mid; } } if(w[l].fr.sc >= a){ r = l; } sort(w.begin() + r,w.end(),cmp2); l = r, r = n - 1; while(r - l > 1){ int mid = (r + l) >> 1; if(w[mid].sc >= b){ r = mid; } else{ l = mid; } } if(w[l].sc >= b){ r = l; } cout << max(n - r,0ll) << endl; } }

Compilation message (stderr)

examination.cpp:40:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(){
      ^
examination.cpp: In function 'int main()':
examination.cpp:9:35: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long long int*' [-Wformat=]
 #define Scan(a) scanf ("%I64d", &a)
                                 ~~^~
 #define scan(a) scanf ("%d", &a)
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  
 
 ~                                  
 using namespace std;
 ~~~~~~~~~~~~~~~~~~~~~              
 
 ~                                  
 const long long INF = (int)1e18 + 7;
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 const int N = (int)3e5 + 7;
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~       
 const int mod = 1000000007;
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~       
 
 ~                                  
 int n, q, s[N], t[N];
 ~~~~~~~~~~~~~~~~~~~~~~             
 vector<pair<pair<int,int >,int >> v,w;
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 ~                                  
 bool cmp(const pair<pair<int,int >,int > &x, const pair<pair<int,int >,int > &y){
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       if(x.fr.fr == y.fr.fr){
       ~~~~~~~~~~~~~~~~~~~~~~~~     
             return x.fr.sc < y.fr.sc;
             ~~~~~~~~~~~~~~~~~~~~~~~~~~
       }
       ~~                           
       else{
       ~~~~~~                       
             return x.fr.fr < y.fr.fr;
             ~~~~~~~~~~~~~~~~~~~~~~~~~~
       }
       ~~                           
 }
 ~~                                 
 bool cmp1(const pair<pair<int,int >,int > &x, const pair<pair<int,int >,int > &y){
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       if(x.fr.sc == y.fr.sc){
       ~~~~~~~~~~~~~~~~~~~~~~~~     
             return x.sc < y.sc;
             ~~~~~~~~~~~~~~~~~~~~   
       }
       ~~                           
       else{
       ~~~~~~                       
             return x.fr.sc < y.fr.sc;
             ~~~~~~~~~~~~~~~~~~~~~~~~~~
       }
       ~~                           
 }
 ~~                                 
 bool cmp2(const pair<pair<int,int >,int > &x, const pair<pair<int,int >,int > &y){
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
             return x.sc < y.sc;
             ~~~~~~~~~~~~~~~~~~~~   
 }
 ~~                                 
 main(){
 ~~~~~~~~                           
       cin >> n >> q;
       ~~~~~~~~~~~~~~~              
       for(int i = 1;i <= n; i++){
       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
             Scan(s[i]);
             ~~~~~~~~~              
examination.cpp:43:13: note: in expansion of macro 'Scan'
             Scan(s[i]);
             ^~~~
examination.cpp:9:35: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long long int*' [-Wformat=]
 #define Scan(a) scanf ("%I64d", &a)
                                 ~~^~
 #define scan(a) scanf ("%d", &a)
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  
 
 ~                                  
 using namespace std;
 ~~~~~~~~~~~~~~~~~~~~~              
 
 ~                                  
 const long long INF = (int)1e18 + 7;
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 const int N = (int)3e5 + 7;
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~       
 const int mod = 1000000007;
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~       
 
 ~                                  
 int n, q, s[N], t[N];
 ~~~~~~~~~~~~~~~~~~~~~~             
 vector<pair<pair<int,int >,int >> v,w;
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 ~                                  
 bool cmp(const pair<pair<int,int >,int > &x, const pair<pair<int,int >,int > &y){
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       if(x.fr.fr == y.fr.fr){
       ~~~~~~~~~~~~~~~~~~~~~~~~     
             return x.fr.sc < y.fr.sc;
             ~~~~~~~~~~~~~~~~~~~~~~~~~~
       }
       ~~                           
       else{
       ~~~~~~                       
             return x.fr.fr < y.fr.fr;
             ~~~~~~~~~~~~~~~~~~~~~~~~~~
       }
       ~~                           
 }
 ~~                                 
 bool cmp1(const pair<pair<int,int >,int > &x, const pair<pair<int,int >,int > &y){
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       if(x.fr.sc == y.fr.sc){
       ~~~~~~~~~~~~~~~~~~~~~~~~     
             return x.sc < y.sc;
             ~~~~~~~~~~~~~~~~~~~~   
       }
       ~~                           
       else{
       ~~~~~~                       
             return x.fr.sc < y.fr.sc;
             ~~~~~~~~~~~~~~~~~~~~~~~~~~
       }
       ~~                           
 }
 ~~                                 
 bool cmp2(const pair<pair<int,int >,int > &x, const pair<pair<int,int >,int > &y){
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
             return x.sc < y.sc;
             ~~~~~~~~~~~~~~~~~~~~   
 }
 ~~                                 
 main(){
 ~~~~~~~~                           
       cin >> n >> q;
       ~~~~~~~~~~~~~~~              
       for(int i = 1;i <= n; i++){
       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
             Scan(s[i]);
             ~~~~~~~~~~~~           
             Scan(t[i]);
             ~~~~~~~~~              
examination.cpp:44:13: note: in expansion of macro 'Scan'
             Scan(t[i]);
             ^~~~
examination.cpp:9:35: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long long int*' [-Wformat=]
 #define Scan(a) scanf ("%I64d", &a)
                                 ~~^~
 #define scan(a) scanf ("%d", &a)
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  
 
 ~                                  
 using namespace std;
 ~~~~~~~~~~~~~~~~~~~~~              
 
 ~                                  
 const long long INF = (int)1e18 + 7;
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 const int N = (int)3e5 + 7;
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~       
 const int mod = 1000000007;
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~       
 
 ~                                  
 int n, q, s[N], t[N];
 ~~~~~~~~~~~~~~~~~~~~~~             
 vector<pair<pair<int,int >,int >> v,w;
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 ~                                  
 bool cmp(const pair<pair<int,int >,int > &x, const pair<pair<int,int >,int > &y){
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       if(x.fr.fr == y.fr.fr){
       ~~~~~~~~~~~~~~~~~~~~~~~~     
             return x.fr.sc < y.fr.sc;
             ~~~~~~~~~~~~~~~~~~~~~~~~~~
       }
       ~~                           
       else{
       ~~~~~~                       
             return x.fr.fr < y.fr.fr;
             ~~~~~~~~~~~~~~~~~~~~~~~~~~
       }
       ~~                           
 }
 ~~                                 
 bool cmp1(const pair<pair<int,int >,int > &x, const pair<pair<int,int >,int > &y){
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       if(x.fr.sc == y.fr.sc){
       ~~~~~~~~~~~~~~~~~~~~~~~~     
             return x.sc < y.sc;
             ~~~~~~~~~~~~~~~~~~~~   
       }
       ~~                           
       else{
       ~~~~~~                       
             return x.fr.sc < y.fr.sc;
             ~~~~~~~~~~~~~~~~~~~~~~~~~~
       }
       ~~                           
 }
 ~~                                 
 bool cmp2(const pair<pair<int,int >,int > &x, const pair<pair<int,int >,int > &y){
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
             return x.sc < y.sc;
             ~~~~~~~~~~~~~~~~~~~~   
 }
 ~~                                 
 main(){
 ~~~~~~~~                           
       cin >> n >> q;
       ~~~~~~~~~~~~~~~              
       for(int i = 1;i <= n; i++){
       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
             Scan(s[i]);
             ~~~~~~~~~~~~           
             Scan(t[i]);
             ~~~~~~~~~~~~           
             v.pb(mk(mk(s[i] + t[i],s[i]),t[i]));
             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       }
       ~~                           
       sort(all(v),cmp);
       ~~~~~~~~~~~~~~~~~~           
       int a, b, c;
       ~~~~~~~~~~~~~                
       while(q--){
       ~~~~~~~~~~~~                 
             Scan(a);
             ~~~~~~                 
examination.cpp:50:13: note: in expansion of macro 'Scan'
             Scan(a);
             ^~~~
examination.cpp:9:35: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long long int*' [-Wformat=]
 #define Scan(a) scanf ("%I64d", &a)
                                 ~~^~
 #define scan(a) scanf ("%d", &a)
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  
 
 ~                                  
 using namespace std;
 ~~~~~~~~~~~~~~~~~~~~~              
 
 ~                                  
 const long long INF = (int)1e18 + 7;
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 const int N = (int)3e5 + 7;
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~       
 const int mod = 1000000007;
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~       
 
 ~                                  
 int n, q, s[N], t[N];
 ~~~~~~~~~~~~~~~~~~~~~~             
 vector<pair<pair<int,int >,int >> v,w;
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 ~                                  
 bool cmp(const pair<pair<int,int >,int > &x, const pair<pair<int,int >,int > &y){
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       if(x.fr.fr == y.fr.fr){
       ~~~~~~~~~~~~~~~~~~~~~~~~     
             return x.fr.sc < y.fr.sc;
             ~~~~~~~~~~~~~~~~~~~~~~~~~~
       }
       ~~                           
       else{
       ~~~~~~                       
             return x.fr.fr < y.fr.fr;
             ~~~~~~~~~~~~~~~~~~~~~~~~~~
       }
       ~~                           
 }
 ~~                                 
 bool cmp1(const pair<pair<int,int >,int > &x, const pair<pair<int,int >,int > &y){
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       if(x.fr.sc == y.fr.sc){
       ~~~~~~~~~~~~~~~~~~~~~~~~     
             return x.sc < y.sc;
             ~~~~~~~~~~~~~~~~~~~~   
       }
       ~~                           
       else{
       ~~~~~~                       
             return x.fr.sc < y.fr.sc;
             ~~~~~~~~~~~~~~~~~~~~~~~~~~
       }
       ~~                           
 }
 ~~                                 
 bool cmp2(const pair<pair<int,int >,int > &x, const pair<pair<int,int >,int > &y){
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
             return x.sc < y.sc;
             ~~~~~~~~~~~~~~~~~~~~   
 }
 ~~                                 
 main(){
 ~~~~~~~~                           
       cin >> n >> q;
       ~~~~~~~~~~~~~~~              
       for(int i = 1;i <= n; i++){
       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
             Scan(s[i]);
             ~~~~~~~~~~~~           
             Scan(t[i]);
             ~~~~~~~~~~~~           
             v.pb(mk(mk(s[i] + t[i],s[i]),t[i]));
             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       }
       ~~                           
       sort(all(v),cmp);
       ~~~~~~~~~~~~~~~~~~           
       int a, b, c;
       ~~~~~~~~~~~~~                
       while(q--){
       ~~~~~~~~~~~~                 
             Scan(a);
             ~~~~~~~~~              
             Scan(b);
             ~~~~~~                 
examination.cpp:51:13: note: in expansion of macro 'Scan'
             Scan(b);
             ^~~~
examination.cpp:9:35: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long long int*' [-Wformat=]
 #define Scan(a) scanf ("%I64d", &a)
                                 ~~^~
 #define scan(a) scanf ("%d", &a)
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  
 
 ~                                  
 using namespace std;
 ~~~~~~~~~~~~~~~~~~~~~              
 
 ~                                  
 const long long INF = (int)1e18 + 7;
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 const int N = (int)3e5 + 7;
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~       
 const int mod = 1000000007;
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~       
 
 ~                                  
 int n, q, s[N], t[N];
 ~~~~~~~~~~~~~~~~~~~~~~             
 vector<pair<pair<int,int >,int >> v,w;
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 ~                                  
 bool cmp(const pair<pair<int,int >,int > &x, const pair<pair<int,int >,int > &y){
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       if(x.fr.fr == y.fr.fr){
       ~~~~~~~~~~~~~~~~~~~~~~~~     
             return x.fr.sc < y.fr.sc;
             ~~~~~~~~~~~~~~~~~~~~~~~~~~
       }
       ~~                           
       else{
       ~~~~~~                       
             return x.fr.fr < y.fr.fr;
             ~~~~~~~~~~~~~~~~~~~~~~~~~~
       }
       ~~                           
 }
 ~~                                 
 bool cmp1(const pair<pair<int,int >,int > &x, const pair<pair<int,int >,int > &y){
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       if(x.fr.sc == y.fr.sc){
       ~~~~~~~~~~~~~~~~~~~~~~~~     
             return x.sc < y.sc;
             ~~~~~~~~~~~~~~~~~~~~   
       }
       ~~                           
       else{
       ~~~~~~                       
             return x.fr.sc < y.fr.sc;
             ~~~~~~~~~~~~~~~~~~~~~~~~~~
       }
       ~~                           
 }
 ~~                                 
 bool cmp2(const pair<pair<int,int >,int > &x, const pair<pair<int,int >,int > &y){
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
             return x.sc < y.sc;
             ~~~~~~~~~~~~~~~~~~~~   
 }
 ~~                                 
 main(){
 ~~~~~~~~                           
       cin >> n >> q;
       ~~~~~~~~~~~~~~~              
       for(int i = 1;i <= n; i++){
       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
             Scan(s[i]);
             ~~~~~~~~~~~~           
             Scan(t[i]);
             ~~~~~~~~~~~~           
             v.pb(mk(mk(s[i] + t[i],s[i]),t[i]));
             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       }
       ~~                           
       sort(all(v),cmp);
       ~~~~~~~~~~~~~~~~~~           
       int a, b, c;
       ~~~~~~~~~~~~~                
       while(q--){
       ~~~~~~~~~~~~                 
             Scan(a);
             ~~~~~~~~~              
             Scan(b);
             ~~~~~~~~~              
             Scan(c);
             ~~~~~~                 
examination.cpp:52:13: note: in expansion of macro 'Scan'
             Scan(c);
             ^~~~
examination.cpp:9:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
 #define Scan(a) scanf ("%I64d", &a)
                 ~~~~~~^~~~~~~~~~~~~
examination.cpp:43:13: note: in expansion of macro 'Scan'
             Scan(s[i]);
             ^~~~
examination.cpp:9:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
 #define Scan(a) scanf ("%I64d", &a)
                 ~~~~~~^~~~~~~~~~~~~
examination.cpp:44:13: note: in expansion of macro 'Scan'
             Scan(t[i]);
             ^~~~
examination.cpp:9:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
 #define Scan(a) scanf ("%I64d", &a)
                 ~~~~~~^~~~~~~~~~~~~
examination.cpp:50:13: note: in expansion of macro 'Scan'
             Scan(a);
             ^~~~
examination.cpp:9:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
 #define Scan(a) scanf ("%I64d", &a)
                 ~~~~~~^~~~~~~~~~~~~
examination.cpp:51:13: note: in expansion of macro 'Scan'
             Scan(b);
             ^~~~
examination.cpp:9:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
 #define Scan(a) scanf ("%I64d", &a)
                 ~~~~~~^~~~~~~~~~~~~
examination.cpp:52:13: note: in expansion of macro 'Scan'
             Scan(c);
             ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...