# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
126816 | 2019-07-08T13:22:17 Z | MohamedAhmed04 | Examination (JOI19_examination) | C++14 | 3000 ms | 137188 KB |
#include <bits/stdc++.h> using namespace std; const int MAX = 1e5 + 5 ; struct custom_hash { static uint64_t splitmix64(uint64_t x) { // http://xorshift.di.unimi.it/splitmix64.c x += 0x9e3779b97f4a7c15; x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9; x = (x ^ (x >> 27)) * 0x94d049bb133111eb; return x ^ (x >> 31); } size_t operator()(pair<uint64_t,uint64_t> x) const { static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x.first + FIXED_RANDOM)^(splitmix64(x.second + FIXED_RANDOM) >> 1); } }; unordered_map< pair<int , int> , int , custom_hash>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]) ; update(a[i] , b[i] , 1) ; } const int N = max(*max_element(a , a + n) , *max_element(b , b + n))+1 ; int cons = query(N , N) ; while(q--) { int x , y , z ; scanf("%d %d %d" , &x , &y , &z) ; printf("%d\n" , cons - query(x-1 , N) - query(N , y-1) + query(x-1 , y-1)) ; } return 0 ; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 380 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 3038 ms | 137188 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 3038 ms | 137188 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 380 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |