結果

問題 No.387 ハンコ
ユーザー yosupotyosupot
提出日時 2016-06-23 15:17:22
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2,300 ms / 5,000 ms
コード長 1,504 bytes
コンパイル時間 531 ms
コンパイル使用メモリ 72,088 KB
実行使用メモリ 8,064 KB
最終ジャッジ日時 2024-04-20 01:13:03
合計ジャッジ時間 21,857 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2,270 ms
8,064 KB
testcase_01 AC 2,300 ms
7,936 KB
testcase_02 AC 2,209 ms
6,940 KB
testcase_03 AC 2,205 ms
6,944 KB
testcase_04 AC 1,061 ms
6,940 KB
testcase_05 AC 1,631 ms
7,296 KB
testcase_06 AC 2,041 ms
7,680 KB
testcase_07 AC 2,210 ms
6,944 KB
testcase_08 AC 2,194 ms
6,944 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:45:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   45 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
main.cpp:48:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   48 |         scanf("%d", &a);
      |         ~~~~~^~~~~~~~~~
main.cpp:54:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   54 |         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 uint = unsigned int;

const int MN = 200128;
const int MD = 100128;
vector<int> g[MD];

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

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];
    }
}

B shiftL(const B &x, int k) { // <<
    B ans; ans.fill(0);
    for (int i = 0; i < BS-k/32; i++) {
        ans[i+k/32] |= x[i]<<(k%32);
        if (i < BS-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);
    }
    B mp; mp.fill(0);
    for (int i = 0; i < n; i++) {
        int x;
        scanf("%d", &x);
        if (x) {
            mp[i/32] |= 1U<<(i%32);
        }
    }
    B ans; ans.fill(0);
    for (int i = 0; i < MD; i++) {
        B res; res.fill(0);
        for (int 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