Submission #126872

#TimeUsernameProblemLanguageResultExecution timeMemory
126872MohamedAhmed04Examination (JOI19_examination)C++14
0 / 100
3060 ms232060 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; using namespace std; const int MAX = 1e5 + 10 ; const int MAX2 = 1e5 ; map< pair<int , int> , int>bit ; void update(int x , int y , int val) { while(x < MAX) { int y1 = y ; while(y1 < MAX) { bit[{x , y1}] += val ; y1 += (y1 & -y1) ; } x += (x & -x) ; } return ; } int query(int x , int y) { int ans = 0 ; while(x > 0) { int y1 = y ; while(y1 > 0) { ans += bit[{x , y1}] ; y1 -= (y1 & -y1) ; } x -= (x & -x) ; } return ans ; } int main() { int n , q ; scanf("%d %d" , &n , &q) ; int a[n] , b[n] ; for(int i = 0 ; i < n ; ++i) { scanf("%d %d" , &a[i] , &b[i]) ; a[i] += 2 ; b[i] += 2 ; update(a[i] , b[i] , 1) ; } while(q--) { int x , y , z ; scanf("%d %d %d" , &x , &y , &z) ; x += 2 ; y += 2 ; printf("%d\n" , query(MAX-1 , MAX-1) - query(x-1 , MAX-1) - query(MAX-1 , y-1) + query(x-1 , y-1)) ; } return 0 ; }

Compilation message (stderr)

examination.cpp: In function 'int main()':
examination.cpp:45:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d" , &n , &q) ;
     ~~~~~^~~~~~~~~~~~~~~~~~~
examination.cpp:49:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d" , &a[i] , &b[i]) ;
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
examination.cpp:57:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d %d" , &x , &y , &z) ;
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...