結果

問題 No.202 1円玉投げ
ユーザー kimiyukikimiyuki
提出日時 2017-03-14 21:47:44
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,071 bytes
コンパイル時間 1,653 ms
コンパイル使用メモリ 150,240 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-23 23:31:05
合計ジャッジ時間 10,666 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 503 ms
4,376 KB
testcase_01 AC 495 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 506 ms
4,380 KB
testcase_17 AC 502 ms
4,380 KB
testcase_18 AC 506 ms
4,380 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 1 ms
4,380 KB
testcase_23 AC 1 ms
4,380 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 1 ms
4,376 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 1 ms
4,376 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 2 ms
4,380 KB
testcase_35 AC 501 ms
4,380 KB
testcase_36 AC 503 ms
4,376 KB
testcase_37 WA -
testcase_38 AC 511 ms
4,380 KB
testcase_39 AC 1 ms
4,376 KB
testcase_40 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC optimize "O3"
#pragma GCC target "tune=native"
#pragma GCC target "avx"
#include <cstdio>
#include <algorithm>
#include <immintrin.h>
#define repeat(i,n) for (int i = 0; (i) < int(n); ++(i))
using namespace std;
template <class T> inline T sq(T x) { return x*x; }
constexpr int max_n = 100000;
__attribute__((aligned(32))) int32_t x[max_n];
__attribute__((aligned(32))) int32_t y[max_n];
__attribute__((aligned(32))) int32_t z[max_n]; // is_removed
int main() {
    int n; scanf("%d", &n);
    repeat (i,n) scanf("%d%d", &x[i], &y[i]);
    int i = 0;
    for (; i+3 < n; i += 4) {
        const __m128i xi = _mm_load_si128((__m128i *)(x + i));
        const __m128i yi = _mm_load_si128((__m128i *)(y + i));
        __m128i zi = _mm_setzero_si128();
        for (int j = 0; j < i; j += 4) {
            __m128i xj = _mm_load_si128((__m128i *)(x + j));
            __m128i yj = _mm_load_si128((__m128i *)(y + j));
            __m128i zj = _mm_load_si128((__m128i *)(z + j));
            xj = _mm_sub_epi32(xj, xi);
            yj = _mm_sub_epi32(yj, yi);
            xj = _mm_mul_epi32(xj, xj);
            yj = _mm_mul_epi32(yj, yj);
            const __m128i d = _mm_add_epi32(xj, yj);
            const __m128i e = _mm_set1_epi32(400);
            __m128i cmp = _mm_cmplt_epi32(d, e);
            zi = _mm_add_epi32(zi, _mm_mul_epi32(cmp, zj));
        }
        _mm_store_si128((__m128i *)(z + i), zi);
        repeat (di, 4) {
            if (z[i+di]) z[i+di] = 1;
            if (not z[i+di]) {
                repeat (dj, di) {
                    if (not z[i+dj] and sq(x[i+dj] - x[i+di]) + sq(y[i+dj] - y[i+di]) < sq(10 + 10) ) {
                        z[i+di] = 1;
                        break;
                    }
                }
            }
        }
    }
    for (; i < n; ++ i) {
        repeat (j,i) {
            if (not z[j] and sq(x[j] - x[i]) + sq(y[j] - y[i]) < sq(10 + 10) ) {
                z[i] = 1;
                break;
            }
        }
    }
    int cnt = count(z, z + n, 0);
    printf("%d\n", cnt);
    return 0;
}
0