提出 #32169715


ソースコード 拡げる

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define MOD 1000000007
#define rep(i,a,n) for (ll i=a;i<(ll)n;i++)
#define per(i,a,n) for (ll i=n;i-->(ll)a;)
#define pb push_back

ll read(){ll r;scanf("%lld",&r);return r;} // read

bool exist[600010];

vector<int> ys[600010]; // 所有真奇数约数

int L[600010];
int R[600010];
int a[600010];

int n,m;
bool w(){
  n = read();
  m = read()*2;
  rep(i,0,n) {
    exist[a[i] = read()] = 1;
  }
  rep(i,1,m/2+1){
    if(i%2 == 0)continue;
    rep(t,3,m/2+1){
      if(t%2 == 0)continue;
      if(i*t > m)break;
      ys[i*t].push_back(i);
    }
  }
  // 先检查是否所有组都有
  rep(i,1,m+1){
    if(i%2==0)continue;
    bool found = false;
    int itr = i;
    while(itr <= m){
      if(exist[itr]){
        found = true;
        break;
      }
      itr*=2;
    }
    if(!found)return false;
  }
  // 计算R
  rep(i,1,m){
    if(i%2 == 0) continue;
    int pwr = 20;
    // 计算它因数对它的限制
    for(auto item:ys[i]){
      pwr = min(pwr,R[item]-1);
    }
    // 找一个范围内且存在的
    bool found = false;
    while(pwr >= 0){
      if(i * (1<<pwr) <= m){
        if(exist[i * (1<<pwr)]){
          R[i] = pwr;
          found = true;
          break;
        }
      }
      pwr--;
    }
    // printf("L %lld => %d\n",i,pwr);
    if(!found) return false; // 不存在合法范围的值
  }
  // 计算L
  per(i,1,m){
    if(i%2 == 0) continue;
    int pwr = 0;
    // 计算它倍数对它的限制
    rep(k,3,m+1){
      if(k%2==0)continue;
      if(i*k > m)break;
      pwr = max(pwr,L[i*k]+1);
    }
    // 找一个范围内且存在的
    bool found = false;
    while( i*(1<<pwr) <= m){
      if(exist[i * (1<<pwr)]){
        L[i] = pwr;
        found = true;
        break;
      }
      pwr++;
    }
    if(!found) return false; // 不存在合法范围的值
    if(L[i] > R[i]) return false;
  }
  // rep(i,1,m){
  //   if(i%2) printf("%lld: [%d %d]\n",i,L[i],R[i]);
  // }
  rep(i,0,n){
    int v = a[i];
    int pwr = 0;
    while(v%2 == 0){
      pwr++;
      v/=2;
    }
    printf("%s\n", L[v] <= pwr && pwr <= R[v]?"Yes":"No");
  }
  return true;
}
int main(){
  if(!w()) rep(i,0,n) printf("No\n");
  return 0;
}

提出情報

提出日時
問題 D - Non-divisible Set
ユーザ cromarmot
言語 C++ (GCC 9.2.1)
得点 700
コード長 2243 Byte
結果 AC
実行時間 324 ms
メモリ 40800 KiB

コンパイルエラー

./Main.cpp: In function ‘ll read()’:
./Main.cpp:10:21: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   10 | ll read(){ll r;scanf("%lld",&r);return r;} // read
      |                ~~~~~^~~~~~~~~~~

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 700 / 700
結果
AC × 3
AC × 47
セット名 テストケース
Sample 00-sample-001.txt, 00-sample-002.txt, 00-sample-003.txt
All 00-sample-001.txt, 00-sample-002.txt, 00-sample-003.txt, 01-random-001.txt, 01-random-002.txt, 01-random-003.txt, 01-random-004.txt, 01-random-005.txt, 01-random-006.txt, 01-random-007.txt, 01-random-008.txt, 01-random-009.txt, 01-random-010.txt, 01-random-011.txt, 01-random-012.txt, 01-random-013.txt, 01-random-014.txt, 01-random-015.txt, 01-random-016.txt, 01-random-017.txt, 01-random-018.txt, 01-random-019.txt, 01-random-020.txt, 02-max-001.txt, 02-max-002.txt, 02-max-003.txt, 02-max-004.txt, 02-max-005.txt, 02-max-006.txt, 02-max-007.txt, 02-max-008.txt, 02-max-009.txt, 02-max-010.txt, 02-max-011.txt, 02-max-012.txt, 03-only-001.txt, 03-only-002.txt, 03-only-003.txt, 03-only-004.txt, 03-only-005.txt, 03-only-006.txt, 03-only-007.txt, 03-only-008.txt, 04-hand-001.txt, 04-hand-002.txt, 04-hand-003.txt, 04-hand-004.txt
ケース名 結果 実行時間 メモリ
00-sample-001.txt AC 15 ms 17684 KiB
00-sample-002.txt AC 16 ms 17704 KiB
00-sample-003.txt AC 15 ms 17740 KiB
01-random-001.txt AC 213 ms 38640 KiB
01-random-002.txt AC 102 ms 29604 KiB
01-random-003.txt AC 152 ms 34612 KiB
01-random-004.txt AC 102 ms 29960 KiB
01-random-005.txt AC 158 ms 35488 KiB
01-random-006.txt AC 141 ms 33304 KiB
01-random-007.txt AC 76 ms 26008 KiB
01-random-008.txt AC 210 ms 38564 KiB
01-random-009.txt AC 174 ms 36848 KiB
01-random-010.txt AC 196 ms 37560 KiB
01-random-011.txt AC 145 ms 34012 KiB
01-random-012.txt AC 191 ms 39124 KiB
01-random-013.txt AC 200 ms 38764 KiB
01-random-014.txt AC 136 ms 34560 KiB
01-random-015.txt AC 107 ms 29952 KiB
01-random-016.txt AC 110 ms 30252 KiB
01-random-017.txt AC 178 ms 37612 KiB
01-random-018.txt AC 89 ms 28156 KiB
01-random-019.txt AC 161 ms 34676 KiB
01-random-020.txt AC 173 ms 36072 KiB
02-max-001.txt AC 193 ms 40112 KiB
02-max-002.txt AC 274 ms 40116 KiB
02-max-003.txt AC 293 ms 40152 KiB
02-max-004.txt AC 324 ms 40456 KiB
02-max-005.txt AC 294 ms 40484 KiB
02-max-006.txt AC 231 ms 40168 KiB
02-max-007.txt AC 223 ms 40172 KiB
02-max-008.txt AC 191 ms 40188 KiB
02-max-009.txt AC 215 ms 40364 KiB
02-max-010.txt AC 223 ms 40448 KiB
02-max-011.txt AC 235 ms 40788 KiB
02-max-012.txt AC 234 ms 40680 KiB
03-only-001.txt AC 174 ms 37512 KiB
03-only-002.txt AC 142 ms 35164 KiB
03-only-003.txt AC 126 ms 33516 KiB
03-only-004.txt AC 62 ms 25420 KiB
03-only-005.txt AC 121 ms 31424 KiB
03-only-006.txt AC 87 ms 27492 KiB
03-only-007.txt AC 53 ms 23420 KiB
03-only-008.txt AC 62 ms 24500 KiB
04-hand-001.txt AC 13 ms 17556 KiB
04-hand-002.txt AC 217 ms 40800 KiB
04-hand-003.txt AC 76 ms 26032 KiB
04-hand-004.txt AC 124 ms 31392 KiB