Submission #359308

# Submission time Handle Problem Language Result Execution time Memory
359308 2021-01-26T17:59:06 Z jhnah917 Examination (JOI19_examination) C++14
0 / 100
21 ms 2284 KB
/******************************
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 = 1 << 17;
constexpr int WORD = 256; // AVX
constexpr int INT_PER_WORD = WORD / sizeof(int);

int N, Q;
alignas(256) unsigned _S[SZ], _T[SZ];

__m256i S[SZ/INT_PER_WORD], T[SZ/INT_PER_WORD], Sum[SZ/INT_PER_WORD], 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] >> _T[i];
    int pv = 0;
    for(int i=0; i<N; i+=INT_PER_WORD, pv++){
        S[pv] = _mm256_load_si256((const __m256i*)_S+i);
        T[pv] = _mm256_load_si256((const __m256i*)_T+i);
        Sum[pv] = _mm256_add_epi32(S[pv], T[pv]);
    }
    for(int i=0; i<Q; i++){
        int x, y, z, ans = 0; cin >> x >> y >> z;
        __m256i cnt = _mm256_set1_epi32(0);
        for(int j=0; j<pv; j++){
            __m256i X = _mm256_cmpgeq_epi32(S[j], x);
            __m256i Y = _mm256_cmpgeq_epi32(T[j], y);
            __m256i Z = _mm256_cmpgeq_epi32(Sum[j], z);
            Flags = _mm256_and_si256(_mm256_and_si256(X, _mm256_and_si256(Y, Z)), _mm256_set1_epi32(1));
            cnt = _mm256_add_epi32(cnt, Flags);
        }
        int tmp[8]; _mm256_store_si256((__m256i*)tmp, cnt);
        for(int j=0; j<8; j++) ans += tmp[j];
        cout << ans << "\n";
    }
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 21 ms 2284 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 21 ms 2284 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -