結果

問題 No.387 ハンコ
ユーザー yosupotyosupot
提出日時 2016-06-23 16:08:53
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 3,363 ms / 5,000 ms
コード長 2,213 bytes
コンパイル時間 586 ms
コンパイル使用メモリ 73,008 KB
実行使用メモリ 9,088 KB
最終ジャッジ日時 2024-04-20 01:24:33
合計ジャッジ時間 34,277 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3,331 ms
9,088 KB
testcase_01 AC 3,363 ms
8,960 KB
testcase_02 AC 3,341 ms
7,424 KB
testcase_03 AC 3,312 ms
7,296 KB
testcase_04 AC 2,970 ms
8,064 KB
testcase_05 AC 3,132 ms
8,192 KB
testcase_06 AC 3,293 ms
8,704 KB
testcase_07 AC 3,325 ms
7,808 KB
testcase_08 AC 3,328 ms
7,316 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:50:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   50 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
main.cpp:53:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   53 |         scanf("%d", &a);
      |         ~~~~~^~~~~~~~~~
main.cpp:59:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   59 |         scanf("%d", &x);
      |         ~~~~~^~~~~~~~~~

ソースコード

diff #

#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm>
#include <queue>
#include <cmath>
#include <bitset>
#include <cassert>
#include <array>

using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;

const int MN = 201024;

using B = array<ull, MN/64>;
const int BS = MN/64;

void orassign(B &l, B r) {
    for (int i = 0; i < BS; i++) {
        l[i] |= r[i];
    }
}
void xorassign(B &l, B r) {
    for (int i = 0; i < BS; i++) {
        l[i] ^= r[i];
    }
}

void shiftLAndOr(const B &x, B &ans, int k) { // <<
    int shift = k%64;
    if (shift) {
        ans[k/64] |= x[0]<<shift;
        for (int i = 1; i < BS-k/64; i++) {
            ans[i+k/64] |= x[i-1]>>(64-shift);
            ans[i+k/64] |= x[i]<<shift;
        }
    } else {
        for (int i = 0; i < BS-k/64; i++) {
            ans[i+k/64] |= x[i];
        }
    }
}
int main() {
    constexpr int MD = 100128;
    vector<int> g[MD];
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        int a;
        scanf("%d", &a);
        g[a].push_back(i);
    }
    B mp; mp.fill(0);
    for (int i = 0; i < n; i++) {
        int x;
        scanf("%d", &x);
        if (x) {
            mp[i/64] |= 1ULL<<(i%64);
        }
    }
    int ans[MN] = {};
//    B ans; ans.fill(0);
    constexpr int U = 4;
    constexpr int BU = 15;
    constexpr ull bmap = 0x1111111111111111;
    for (int fe = 0; fe < MD/BU; fe++) {
        B res[BU];
        for (int i = 0; i < BU; i++) {
            res[i].fill(0);
            for (int d: g[fe*BU+i]) {
                shiftLAndOr(mp, res[i], d);
            }
        }
        for (int i = 0; i < BS; i++) {
            for (int b = 0; b < U; b++) {
                ull sm = 0;
                for (int j = 0; j < BU; j++) {
                    sm += ((res[j][i]>>b) & bmap);
                }
                for (int j = 0; j < 64/U; j++) {
                    ans[i*64+j*U+b] += (sm>>(j*U))&((1<<U)-1);
                }
            }
        }
    }
    for (int i = 0; i < 2*n-1; i++) {
        if (ans[i] % 2) {
            printf("ODD\n");
        } else {
            printf("EVEN\n");
        }
    }
    return 0;
}
0