結果

問題 No.879 Range Mod 2 Query
ユーザー tnakao0123tnakao0123
提出日時 2019-09-09 08:24:13
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,192 bytes
コンパイル時間 740 ms
コンパイル使用メモリ 89,292 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-10 10:52:23
合計ジャッジ時間 7,407 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 TLE -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

/*  -*- coding: utf-8 -*-
 *
 * f.cc: F - Many Slimes
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 18;
const int MAX_M = 1 << MAX_N;

/* typedef */

typedef pair<int,int> pii;
typedef multiset<int> msi;

/* global variables */

int as[MAX_M], vs[MAX_M];
msi xset;

/* subroutines */

/* main */

int main() {
  int n;
  scanf("%d", &n);
  int m = 1 << n;

  for (int i = 0; i < m; i++) scanf("%d", as + i);
  sort(as, as + m);

  xset.insert(m);

  for (int i = m - 1; i >= 0;) {
    int k = 1;
    while (k <= i && as[i] == as[i - k]) k++;
    i -= k;

    if (xset.size() < k) {
      puts("No");
      return 0;
    }

    msi::iterator mit = xset.end();
    for (int j = 0; j < k; j++) vs[j] = *(--mit);
    xset.erase(mit, xset.end());

    for (int j = 0; j < k; j++)
      for (int b = 1; b < vs[j]; b <<= 1) xset.insert(b);
  }

  puts("Yes");
  return 0;
}
0