結果

問題 No.387 ハンコ
ユーザー yosupotyosupot
提出日時 2016-06-23 15:11:49
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,559 bytes
コンパイル時間 670 ms
コンパイル使用メモリ 72,436 KB
実行使用メモリ 8,256 KB
最終ジャッジ日時 2024-04-20 01:10:47
合計ジャッジ時間 11,246 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 607 ms
6,944 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:44:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   44 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
main.cpp:47:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   47 |         scanf("%d", &a);
      |         ~~~~~^~~~~~~~~~
main.cpp:53:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   53 |         scanf("%d", &xx);
      |         ~~~~~^~~~~~~~~~~

ソースコード

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 uint = unsigned int;

const int MN = 100128;

vector<int> g[MN];

using B = array<uint, MN/32>;

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

B shiftL(const B &x, int k) { // <<
    B ans; ans.fill(0);
    for (int i = 0; i < MN/32-k/32; i++) {
        ans[i+k/32] |= x[i]<<(k%32);
        if (i < MN/32-k/32-1 && k%32) {
            ans[i+k/32+1] |= x[i]>>(32-k%32);
        }
    }
    return ans;
}
int main() {
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        int a;
        scanf("%d", &a);
        g[a].push_back(i);
    }
    bool x[n];
    for (int i = 0; i < n; i++) {
        int xx;
        scanf("%d", &xx);
        x[i] = (xx == 1);
    }

    B mp; mp.fill(0);
    for (uint i = 0; i < n; i++) {
        if (x[i]) {
            mp[i/32] |= 1U<<(i%32);
        }
    }
    B ans; ans.fill(0);
    for (uint i = 0; i < MN; i++) {
        B res; res.fill(0);
        for (uint d: g[i]) {
            orassign(res, shiftL(mp, d));
        }
        xorassign(ans, res);
    }
    for (int i = 0; i < 2*n-1; i++) {
        if (ans[i/32] & (1U<<(i%32))) {
            printf("ODD\n");
        } else {
            printf("EVEN\n");
        }
    }
    return 0;
}
0