/******************************
Author: jhnah917(Justice_Hui)
g++ -std=c++17 -DLOCAL
******************************/
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target ("avx,avx2,fma")
#include <bits/stdc++.h>
#include <immintrin.h>
using namespace std;
using uint = unsigned;
using ll = long long;
using ull = unsigned long long;
constexpr int SZ = 100000;
union Fuck{
__m256i vec;
int arr[8];
};
int N, Q;
alignas(256) Fuck S[SZ/8], T[SZ/8], U[SZ/8], Flags;
__m256i _mm256_cmpgeq_epi32(__m256i a, __m256i b){
__m256i ret = _mm256_cmpeq_epi32(a, b);
ret = _mm256_or_si256(ret, _mm256_cmpgt_epi32(a, b));
return ret;
}
__m256i _mm256_cmpgeq_epi32(__m256i a, unsigned b){
return _mm256_cmpgeq_epi32(a, _mm256_set1_epi32(b));
}
int main(){
ios_base::sync_with_stdio(false); cin.tie(nullptr);
cin >> N >> Q;
for(int i=0; i<N; i++) cin >> S[i>>3].arr[i&7] >> T[i>>3].arr[i&7];
for(int i=0; i<SZ/8; i++){
U[i].vec = _mm256_add_epi32(S[i].vec, T[i].vec);
}
for(int i=0; i<Q; i++){
int x, y, z, ans = 0; cin >> x >> y >> z;
Fuck cnt; cnt.vec = _mm256_set1_epi32(0);
for(int j=0; j<SZ/8; j++){
__m256i X = _mm256_cmpgeq_epi32(S[j].vec, x);
__m256i Y = _mm256_cmpgeq_epi32(T[j].vec, y);
__m256i Z = _mm256_cmpgeq_epi32(U[j].vec, z);
Flags.vec = _mm256_and_si256(_mm256_and_si256(X, _mm256_and_si256(Y, Z)), _mm256_set1_epi32(1));
cnt.vec = _mm256_add_epi32(cnt.vec, Flags.vec);
}
for(int j=0; j<8; j++) ans += cnt.arr[j];
cout << ans << "\n";
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
780 KB |
Output is correct |
2 |
Correct |
2 ms |
748 KB |
Output is correct |
3 |
Correct |
1 ms |
748 KB |
Output is correct |
4 |
Correct |
1 ms |
748 KB |
Output is correct |
5 |
Correct |
1 ms |
748 KB |
Output is correct |
6 |
Correct |
1 ms |
748 KB |
Output is correct |
7 |
Correct |
143 ms |
1004 KB |
Output is correct |
8 |
Correct |
147 ms |
748 KB |
Output is correct |
9 |
Correct |
143 ms |
748 KB |
Output is correct |
10 |
Correct |
145 ms |
876 KB |
Output is correct |
11 |
Correct |
144 ms |
876 KB |
Output is correct |
12 |
Incorrect |
145 ms |
948 KB |
Output isn't correct |
13 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3075 ms |
2276 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3075 ms |
2276 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
780 KB |
Output is correct |
2 |
Correct |
2 ms |
748 KB |
Output is correct |
3 |
Correct |
1 ms |
748 KB |
Output is correct |
4 |
Correct |
1 ms |
748 KB |
Output is correct |
5 |
Correct |
1 ms |
748 KB |
Output is correct |
6 |
Correct |
1 ms |
748 KB |
Output is correct |
7 |
Correct |
143 ms |
1004 KB |
Output is correct |
8 |
Correct |
147 ms |
748 KB |
Output is correct |
9 |
Correct |
143 ms |
748 KB |
Output is correct |
10 |
Correct |
145 ms |
876 KB |
Output is correct |
11 |
Correct |
144 ms |
876 KB |
Output is correct |
12 |
Incorrect |
145 ms |
948 KB |
Output isn't correct |
13 |
Halted |
0 ms |
0 KB |
- |