結果

問題 No.387 ハンコ
ユーザー yosupotyosupot
提出日時 2016-06-23 15:19:04
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 1,212 ms / 5,000 ms
コード長 1,539 bytes
コンパイル時間 712 ms
コンパイル使用メモリ 72,084 KB
実行使用メモリ 7,936 KB
最終ジャッジ日時 2024-04-20 01:14:17
合計ジャッジ時間 12,402 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,186 ms
7,936 KB
testcase_01 AC 1,165 ms
7,936 KB
testcase_02 AC 1,212 ms
6,272 KB
testcase_03 AC 1,176 ms
6,272 KB
testcase_04 AC 573 ms
6,656 KB
testcase_05 AC 847 ms
7,296 KB
testcase_06 AC 1,035 ms
7,680 KB
testcase_07 AC 1,159 ms
6,656 KB
testcase_08 AC 1,165 ms
6,400 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:46:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   46 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
main.cpp:49:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   49 |         scanf("%d", &a);
      |         ~~~~~^~~~~~~~~~
main.cpp:55:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   55 |         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 = 200128;
const int MD = 100128;
vector<int> g[MD];

using B = array<ull, MN/64>;
const size_t 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];
    }
}

B shiftL(const B &x, int k) { // <<
    B ans; ans.fill(0);
    for (int i = 0; i < BS-k/64; i++) {
        ans[i+k/64] |= x[i]<<(k%64);
        if (i < BS-k/64-1 && k%64) {
            ans[i+k/64+1] |= x[i]>>(64-k%64);
        }
    }
    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/64] |= 1ULL<<(i%64);
        }
    }
    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/64] & (1ULL<<(i%64))) {
            printf("ODD\n");
        } else {
            printf("EVEN\n");
        }
    }
    return 0;
}
0